given the following primefaces Data
<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>
how does someone get (on the server side) the filter "Text" value, given by the user in the filter textcolumn ?
i tried to listen to the filter event with "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));
}
}
}
but I can't start something with it. are they any other options ? like working with the DataTable as a bound Component, or else ?
thanks
This works just fine for me...
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}") ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With