For this project I have to provide a "combo box" type control. The user should allowed to enter *any text* and the control will filter on that entry.
For example: if the control has the options of "Alpha, Beta, Gamma, Delta" and the user entered "ta", then "Beta" and "Delta" should appear in the dropdown list.
If the control has the options of "London, Manchester, Winchester, Paris" and the and the user entered "est", then "Manchester" and "Winchester" should appear in the dropdown list.
I know the RichFaces suggestion box exists, but that can only do exact matches I believe, not handle free-text entries.
Does anyone know how I can possibly provide this functionality? I guess I could use a normal inputbox and JQuery, but I'd rather do it all within the RichFaces framework. Will I have to include other implementations (such as Tomahawk) and is that even wise? I'm not looking for the complete solution, but even an idea of where to start or find an example of something similar would be a big help!
I have already swapped once from Apache Trinidad to IBM RichFaces - if at all possible, I'd like to avoid having to switch back; although I will do that if I have to.
I believe richfaces combox has a suggestion values attribute which takes a list as an input.
You could filter out the values in your original list based on the user input and update your suggestion values list
original list = Alpha,Beta,Theta
user ip = eta
Filter out values from original list (simple java string.contains) should work and add to the suggestion values list and re render the combo box.
I have not tried this but might be of some use
Joined: Jun 09, 2009
Thanks Kavita, that's an idea. I did look into the RichFaces Suggestion box a bit more and it is more powerful than I originally thought. I can define the "autocomplete" to be whatever I want; it's basically your exact suggestion as it happens.
At the moment the "solution" appears to be a basic inputbox and JQuery, that way we can keep all the processing on the client. I have not tried this yet, so may well go back to your idea if I hit problems.
Joined: Jun 09, 2009
I don't particularly want to "wake the dead", but I do want to add my solution in case anyone else hits similar problems.
Long story short - with large data sets the RichFaces Suggestion Box suffers from performance problems (I had to handle 2,500+ possibly values). RichFaces includes JQuery though, and that is your potential solution.
Rather than using a RichFaces Suggestion box, I used a normal h:inputText and used JQuery to bind the JQuery:Autocomplete plugin to that textbox.
The JQuery:Autocomplete functionality is broadly similar to the suggestion box and it also supports AJAX.