Richfaces suggestionbox

I am trying to use List of SelectItems with the richFaces suggestionBox component. The problem is that I need to save the identifier, not the SelectItem label. The suggestionBox always seems to keep the shortcut and cause the problem. Is there a way out of this problem?

+2
source share
1 answer

I am using 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>

SetPropertyActionListener does the work you are looking for. I also have a converter on my input text, so the user can just enter something (UN location codes in my copy), and I can try to parse this in the converter into an object.

+5
source

All Articles