简体   繁体   中英

How Keep session on Primefaces DataTable Filter

I have a page that use Primefaces Datatable, basically the ManagedBean queries the database and displays information in a DataTable as a report and I use the option filterBy to filter.

The information is updated automatically, by a refresh on page, my problem is when the system reloads the page, the system loses the information typed in the filter, then the user has to typed infortions in filter again.

I need to keep the information inputed by the user, then I think that I need to keep the session of the filter of my page, I think that it can solve my problem.

It would appear as though PrimeFaces does not support saving the data.table's filter value at this time (as of PF 3.2).

Would suggest that instead, you implement a header facet for the column and in it, add an input field that is bound to a method on your backing bean that will perform the filter. That way, you can then store the value of the filter field in View Scope (either using a View Scope managed bean or Tomahawk's saveState component). Note the input field can (and perhaps should) be set up with ap:ajax component so that when the user changes a value on the field, the backing bean method is called, so that the filter will perform exactly the same was it would had you implemented it using p:column's filterBy attribute.

I have done the above when I wanted to have a filterBy use a popup calendar for a date and it works quite well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM