我正在尝试将 SelectItems 列表与 RichFaces suggestBox 组件一起使用。问题是我需要存储 id 而不是 SelectItem 的标签。似乎 suggestBox 总是存储标签,这导致了问题。有办法解决这个问题吗?
最佳答案
我使用这样的东西:
<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 完成您正在寻找的工作。我的输入文本上还有一个转换器,因此用户只需输入一些内容(我的实例中的联合国位置代码),我就可以尝试在转换器中将其解析为对象。
关于java - 富人意见箱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1681559/