views:

255

answers:

2

I'm currently playing with the richfaces comboBox. You can check is here: http://livedemo.exadel.com/richfaces-demo/richfaces/comboBox.jsf?c=comboBox&tab=usage

I would like to know if there a way change how the suggestion are made in the combo box, instead of suggesting juste word that start with the same letter it would suggest word that have other word starting with that letter or combination of letter.

Here a example from the demo: From the current combo box if I type "Mo" the combo show Mongomery and " Monpelier" but I would like it to detect "Des Moines" has well since "Moines" start with "Mo".

+1  A: 

You can use <rich:suggestionBox> and define the custom autocomplete algorithm.

It's not possible with <rich:comboBox> directly, but if you extend it and define it as a custom component, it is possible, by overriding the encodeSuggestionValues() method of ComboBoxBaseRenderer (actually of ComboBoxRenderer)

Bozho
Thanks, I'll post the code once I've got something working with a combobox
Chris
I used the example found here : http://mkblog.exadel.com/ria/richfaces-ria/richfaces-suggestion-box-component/ and I used split(" ") on the string I'm comparing the user input.
Chris
A: 

Hi guys...

If we want to use rich:comboBox with a better suggestion method (not only "begins with" but "contains" or "contains any") we could enhance it on the client-side (as I did)...

In this article I share my (working) approach:

Enhanced rich:comboBox: Values (not only Text) and RegExp Suggestions http://community.jboss.org/docs/DOC-15534

So please test it and let me know what you think.

God bless you.

Best regards, Luis Tama

luiggitama