I have a datatable with a filter
The filter work good but the result of filter doesn't work. I call ajax inside of p:inputText to try to refresh the result but doesn't work
<h:outputText value="Result"/><h:outputText id="sizeFilterMyWork" value="#{caseManagement.myWork.size()}" />
<h:outputText value="Filter" id="myCaseOutputTextSearch" />
<p:inputText id="globalFilter" onkeyup="PF('myCaseTable').filter()" style="width:150px" >
<p:ajax event="keyup" update="sizeFilterMyWork" listener="#{caseManagement.getSizefilteredMyWork}"></p:ajax>
</p:inputText>
In the bean I have the list of myWork
(with get and set) and a list used for the filter (with get and set), when the page is load the result call the size of the list of my work, then, when I use the filter the datatable is shrinking (so it's work) but the number of result doesnt change. Ajax should call the method getSizefilteredMyWork
and update the result but doesnt work
Bean
private List<Case> myWork = new ArrayList<Case>(); // get and set
private List<Case> filteredMyWork; //get and set
public int getSizefilteredMyWork(final AjaxBehaviorEvent event)
{
return filteredMyWork.size();
}
How can I fix it?
Your listener method's return value is ignored but you don't need it because the outputText
will get its value directly from myWork
. It should get the size of the filteredMyWork
list instead.
You could try replacing the ìnputText
p:ajax
with one in the p:datatable
:
<p:ajax event="filter" process="@this" update="sizeFilterMyWork" />