简体   繁体   English

JSF2中的可搜索Selectone菜单或质数中的autoComplete

[英]Searchable Selectonemenu in JSF2 or autoComplete in primefaces

Any one with an example of implementing a searchable selectonemenu in JSF2. 任何人都带有在JSF2中实现可搜索的selectone菜单的示例。 One should be able to type and then select from the suggestions. 一个应该能够键入,然后从建议中选择。 The suggestions are many columns and are results from the database table. 这些建议有很多列,是数据库表的结果。 Tried this but i have failed to implement its custom converter using the autoComplete component of primefaces. 尝试了此操作,但我无法使用primefaces的autoComplete组件实现其自定义转换器。 Any one out there with a good lead/advise/url link on this. 任何人在那里都具有良好的线索/建议/网址链接。 Thanks 谢谢

Make use of an inputtext that the user types, and then a datatable that gets updated from the database on every keyup in the input text. 利用用户键入的输入文本,然后使用数据表,该数据表在输入文本中的每个键上都会从数据库中更新。 Then you can use a button in a column to select from the suggestions or use jquery to put a listener on every row in the suggestions. 然后,您可以使用列中的按钮从建议中进行选择,或者使用jquery在建议中的每一行上放置一个侦听器。 Then use css to make a simulation of a selectonemenu 然后使用CSS进行Selectone菜单的模拟

A short exemple: 简短的例子:

View: 视图:

<h:inputText value="#{backBean.searchWord}">
    <p:ajax event="keyup" update="suggestionsTable"/>
    <p:ajax event="click" update="suggestionsTable"/>
</h:inputText>

<h:dataTable id="suggestionsTable" value="#{backBean.suggestionsList}" var="item" cellpadding="5" >
    <h:column>
        <h:outputText value="#{item.someItem}"></h:outputText>
    </h:column>
</h:dataTable>

Bean: 豆角,扁豆:

public class backBean {

    private List suggestionsList = new ArrayList();
    private String searchWord;

    public void setSearchWord(String searchWord) {
        suggestionsList = // items from your database
        this.searchWord = searchWord;
    }

    public String getSearchWord()
    {
        return this.searchWord;
    }

    public List getSuggestionsList()
    {
        return this.suggestionsList;
    }

    public void setSuggestionsList(List inList)
    {
        this.suggestionsList = inList;
    }

}

Thank to those who replied my post and sorry i took all this long to respond. 感谢那些回答我的帖子的人,对不起,我花了这么长时间回复。 I was able to find a solution using primefaces autoComplete component with Pojo by implementing a custom converter. 通过实现自定义转换器,我能够将primefaces autoComplete组件与Pojo结合使用来找到解决方案。 More info https://www.primefaces.org/showcase/ui/input/autoComplete.xhtml 更多信息https://www.primefaces.org/showcase/ui/input/autoComplete.xhtml

In case one needs more clarification, please let me know. 如果需要进一步说明,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM