Richfaces suggestionbox

穿精又带淫゛_ 提交于 2019-12-22 13:32:06

问题


I'm trying to use a List of SelectItems with RichFaces suggestionBox component. The problem is I need to store the id rather than the label of the SelectItem. It seems that the suggestionBox always stores the label and that's causing a problem. Is there a way out of this problem?


回答1:


I use something like this:

<h:inputText
    id="suggest"
    value="#{someBean.someStringValue}"
    converter="#{myStringValueConverter}">
    <a:support event="onblur" ajaxSingle="true"/>
</h:inputText>

<rich:suggestionbox for="suggest"
    suggestionAction="#{suggestionInstance.suggestion}"
    var="s"
    fetchValue="#{s.someValue}"
    ajaxSingle="true">
    <h:column>
        <h:outputText value="#{s.anotherValue}"/>
    </h:column>
    <h:column>
        <h:outputText value="#{s.yetAnotherValue}"/>
    </h:column>
    <a:support event="onselect" ajaxSingle="true" reRender="target">
        <f:setPropertyActionListener value="#{s}" target="#{someBean.someObject}" />
    </a:support>
</rich:suggestionbox>

The setPropertyActionListener does the job that you are looking for. I also have a converter on my input text so the user can just type in something (UN Location codes in my instance) and I can try to parse this in the converter to an Object.



来源:https://stackoverflow.com/questions/1681559/richfaces-suggestionbox

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