質問

I am looking for JSF component similar to auto suggestion or combo-box but with extended functionality that options in drop down suggestions reappears after user has clicked space. In other words, lets say combo-box has options "Option1", "Option 2", "Option 3", component should provide capability so that user can enter "Option 1 abc Option 2 xyz Option 3" by selecting "Option 1" first, abc , hitting space should present drop down list again where user can select "Option 2".

I am not sure if something similar already exists. If anyone has idea, please let me know.

If you need more explanation, please let me know.

役に立ちましたか?

解決 2

RichFaces provide a autocomplete component, is called RichFaces Autocomplete.

In the link, you can see the second example, using ',' or ' ' you can select many values.

    <rich:autocomplete mode="cachedAjax" tokens=", " minChars="1"
        autofill="false" 
        autocompleteMethod="#{autocompleteBean.autocomplete}" />

In the Showcase source, you can see the bean implementation

    public List<String> autocomplete(String prefix) {
        ArrayList<String> result = new ArrayList<String>();
        if ((prefix == null) || (prefix.length() == 0)) {
            for (int i = 0; i < 10; i++) {
                result.add(capitals.get(i).getState());
            }
        } else {
            Iterator<Capital> iterator = capitals.iterator();
            while (iterator.hasNext()) {
                Capital elem = ((Capital) iterator.next());
                if ((elem.getState() != null && elem.getState().toLowerCase().indexOf(prefix.toLowerCase()) == 0)
                        || "".equals(prefix)) {
                    result.add(elem.getState());
                }
            }
        }

Sorry for my bad english. Cheers.

他のヒント

you can use tagit jquery plugin

tagit jquery plugin

Demo: tagit jquery plugin demo

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top