1
votes

I have a p:dataTable which stores the results of a processed form, and I perform the following actions:

  1. Fill form values.
  2. Submit.
  3. Data table is populated -- filter on any column.
  4. Change form values.
  5. Submit.
  6. Data table is populated with new results.
  7. Sort on any column -- filtered results from #3 are displayed.

I have an arraylist for the filtered values, but I am not doing anything to it in the bean. On submit, I am calling an actionListener which casts the dataTable to primefaces.components.datatable.DataTable and then calling a resetValue() on it (see code snippet below), before I process the form.

I've tried multiple ways of resetting, clearing and updating the dataTable, but I'm not able to get around the above issue. Just for reference, this is my p:dataTable tag:

<p:dataTable
            id="resultsDataTable"
            rendered="#{entityReportBean.isResultsPopulated}"
            var="change"
            value="#{entityReportBean.entityChangeDto}"
            styleClass="resultsPanel"
            rows="100"
            paginator="true"
            paginatorPosition="top"
            paginatorTemplate="#{PreviousPageLink}  Previous  {CurrentPageReport}  Next  {NextPageLink}"
            filterEvent="enter"
            filteredValue="#{entityReportBean.filteredResults}" >

and this is the actionListener:

    public void onSubmit() {
            FacesContext context = FacesContext.getCurrentInstance();
            DataTable resultsTable = (DataTable) context.getViewRoot().findComponent("results:resultsDataTable");
            resultsTable.resetValue();
                ...

I am fairly new to JSF/Primefaces so there might be some basic operation I'm unaware of. Any suggestions?

1

1 Answers

1
votes

So I realized that there was no point trying to do anything in my actionListener as that is not being invoked on sort. So I added an ajax 'sort' event on the dataTable and added a resultsTable.updateValue(entityChangeDto); to the listener. Now all is well.