Richfaces暗示框 [英] Richfaces suggestionbox
问题描述
我正在尝试使用带有RichFaces suggestionBox组件的SelectItems列表。问题是我需要存储id而不是SelectItem的标签。似乎suggestionBox总是存储标签,这会导致问题。有没有办法摆脱这个问题?
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?
推荐答案
我使用这样的东西:
<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执行您要查找的作业。我的输入文本也有一个转换器,因此用户只需键入一些内容(我的实例中的UN位置代码),我可以尝试在转换器中将其解析为Object。
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.
这篇关于Richfaces暗示框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!