How to change the suggestion made by the richfaces combobox?

爱⌒轻易说出口 提交于 2019-12-08 01:48:48

问题


I'm currently playing with the richfaces comboBox. You can check is here

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:


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)




回答2:


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.

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



来源:https://stackoverflow.com/questions/2773432/how-to-change-the-suggestion-made-by-the-richfaces-combobox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!