There might be cases where it’d be cool to make users enter the values of an JSF inputtext using a slider. One possible way to do this is to create a custom JSF component and render the javascript but this is hard to create, test and maintain. On the otherhand thanks to the best jsf viewhandler Facelets, it’s sooo easy. Actually I’ve created this example to demonstrate how it’s easy to do stuff like this.
Here’s the slider.xhtml built on top of the cool scriptaculous slider widget;
| <ui:composition> <t:inputText id=”#{id}” style=”width:100px” value=”#{value}” forceId=”true”></t:inputText> <div id=”#{id}_track_id” style=”width:105px;background-color:#aaa;height:5px;”> <script type=”text/javascript”> |
After declaring slider tag in your facelets-taglib file, it’s all set and ready to use as;
| <barca:slider id=”ageSlider” value=”#{CustomerCreate.customer.age}” minimum=”18″ maximum=”50″></barca:slider> |
How it looks