I am using richfaces datatable and my aim is to write a custom filter methods on each column:
Here is the code:
<rich:column filterBy="#{account.name}" filterEvent="onkeyup" filterValue="#{clientPortfolioHome.myName}" filterMethod="#{clientPortfolioHome.getFilteredValue}" > <f:facet name="header"> <h:outputText value="#{messages['label.account.name']}"/> </f:facet> <h:outputText id="portfolioName" value="#{account.name}"/> </rich:column>
String myName; public String getMyName() { return myName; } public void setMyName(String myName) { this.myName = myName; } public int getMandateId() { return mandateId; } public void setMandateId(int mandateId) { this.mandateId = mandateId; } public boolean getFilteredValue(Object object){ ClientPortfolio clientPortfolio = (ClientPortfolio)object; if(myName!=null){ return clientPortfolio.getName().equalsIgnoreCase(this.myName); }else { return true; } }
using filterMethod or filterExpression means that you should write your own inputs and care about the requests. explore our external filtering demo. And no need to specify filterBy in this case.