Create a JSF Slider in 5 minutes
Posted by cagataycivici on March 19, 2007
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

March 19, 2007 at 2:01 pm
hello,
your blog is great but i can’t find any rss feed
does it exists?
regads
March 19, 2007 at 2:24 pm
Hi, doesn’t this work? http://www.jroller.com/rss/cagataycivici
March 19, 2007 at 2:28 pm
works,
but I think he misses a *link* to the RSS
March 19, 2007 at 2:38 pm
I see, yes you’re right, I should’ve added one:)
March 19, 2007 at 3:02 pm
Btw. I think the minimum=”18″ maximum=”50″ should be handled by (double/long) range validator
March 19, 2007 at 3:19 pm
great, it works
didn’t find it in the page…
thanks
March 20, 2007 at 12:08 am
Cagatay,
I like that fast approach for customizing JSF components.
Excellant work (y).
March 27, 2007 at 9:42 pm
Once again Facelets makes life much easier…Or you can use this component that uses the same scriptaculous library and works with JSP and Facelets.
http://livedemo.exadel.com/richfaces-demo/richfaces/dataFilterSlider.jsf
April 8, 2008 at 7:23 am
Totally agree. Composite components are the way forward…
April 11, 2008 at 8:23 pm
cant get the slider to work with events other than page load
May 19, 2008 at 10:31 am
dkbmaq lmvdu rzyup cqgoh yqvlhci ldfiko penw
July 11, 2008 at 8:04 pm
It would take same amount of time in php or jsp. Why is this a big deal?