Storing DataTable settings in 2.2.1

UI Components for JSF
Post Reply
Tom
Posts: 1
Joined: 07 Nov 2011, 14:55

07 Nov 2011, 15:19

Hi all,

I try to store the settings of a lazy primefaces datatable into a session (we are view scoped and cannot change this). The idea is to follow links and
on return the settings should be restored as before when the page has been left.

I use a PhaseListener to get the Datatable settings and store them into the session and restore them by binding a Bean to the datatable.

PhaseListener:

Code: Select all

    @Override
    public void beforePhase(final PhaseEvent event) {
        FacesContext context = event.getFacesContext();
        UIViewRoot viewRoot = context.getViewRoot();

        DataTable dataTable = findDataTableInComponent(viewRoot);
        if (dataTable != null) {
           // store properties in session with viewRoot as key
        }
     }

    @Override
    public PhaseId getPhaseId() {
        return PhaseId.RENDER_RESPONSE;
    }
DataTableBinding

Code: Select all

    public DataTable getDataTable() {
        return this.dataTable;
    }

    public void setDataTable(final DataTable dataTable) {
            // get properties for current viewId from session ...
            if (dataTable != null) {
                dataTable.setPage(...);
                dataTable.setFirst(...);
                dataTable.setFilters(...);
            }
            dataTable.setLazy(true);
        }
        this.dataTable = dataTable;
    }
Everything works fine, on reload the table rendered with filteres, page settings and so on, but The Table ist only restored partially on new page requests, only tbody is replaced.

The column headers do therefore not reflect the stored changes.

So here comes the question:

How do I request an update of filter column headers?
I may use

Code: Select all

jQuery(document).ready( function() {}
but I have no idea how to get the exact filter settings from our session on the JS side.

Or is it possible to trigger the header replacement from the server side?

We may unfortunately not update to 3.x Primefaces.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 28 guests