jsf-2 - 素面 : how to get the value of a Filter column text

标签 jsf-2 primefaces

给定以下primefaces数据

<p:dataTable value="#{cc.attributes.playerCollection}" var="player"
    widgetVar="playerWidgetTable" emptyMessage="#{uimsg.ui_not_recordsfound}">
    <!-- filter event handler  -->
    <p:ajax event="filter" listener="#{cc.attributes.viewBean.listenFilter}" update="@this"/>

    <!-- Player first name  -->
    <p:column id="firstnameColumn" headerText="#{uimsg.firstname}"
        filterBy="#{player.firstName}" filterMatchMode="contains">
        <h:outputText value="#{player.firstName}" />
    </p:column>
</p:dataTable>

某人如何获得(在服务器端)用户在过滤器文本列中给出的过滤器“文本”值?

我试着用“listenFilter”监听过滤事件:

@ManagedBean
@ViewScoped
public class PlayerListBean implements Serializable {

......

    public void listenFilter(FilterEvent event) {
        // update datasource
        Map<String, String> tempString = event.getFilters();

        System.out.println("size filter: "+ tempString.size());
        for (String key : tempString.keySet()) {
            System.out.println("key: " + key + " \t values: "
                    + tempString.get(key));

        }

    }

}

但我无法用它开始。 他们还有其他选择吗?喜欢将 DataTable 作为绑定(bind)组件使用,否则?

谢谢

最佳答案

这对我来说很好......

public void listenFilter(FilterEvent event) {

    DataTable table = (DataTable) event.getSource();
    Map<String, String>  filters = table.getFilters();
    //grab the value from the required map key (somePropertyName if your filterBy 
     looks like filterBy="#{myBean.somePropertyName}") ... 

}

关于jsf-2 - 素面 : how to get the value of a Filter column text,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13365451/

相关文章:

jsf-2 - 如何指定消息是否应显示在 p :growl or p:messages? 中

java - <f :convertNumber> use the right number separator when using patterns to format currency?

JSF action、actionlistener、onClick的区别

css - 使用内联 Css 覆盖 primefaces 中的用户定义的 css

netbeans - 如何为 primefaces 元素启用 javadoc?

java - 在jsp中使用jsf创建一个弹出窗口

css - JSF CSS 优先顺序

jsf - 是否有可以关闭 primefaces 覆盖面板的 java 命令?

javascript - Primefaces inputMask 只接受十六进制

jsf-2 - 什么是 PrimeFaces p :editor based on?