Richfaces暗示框 [英] Richfaces suggestionbox

查看:110
本文介绍了Richfaces暗示框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用带有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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆