Mixing AJAX requests with Flash scope objects not working

Posted by AlanObject on Stack Overflow See other posts from Stack Overflow or by AlanObject
Published on 2012-09-21T21:35:28Z Indexed on 2012/09/21 21:38 UTC
Read the original article Hit count: 1416

Filed under:
|
|

I have a JSF page that displays a table from an object called TableQuery that supports stateful pagination, sorting, etc. The bean that accesses the object is a RequestScoped object, and it attempts to preserve the TableQuery by storing it the flash map. The accessor method looks like this:

public TableQuery<SysLog> getQuery() {
    if (query != null) return query;
    Flash flash = FacesContext.getCurrentInstance().
            getExternalContext().getFlash();
    query = (TableQuery) flash.get("Query");
    if (query != null) System.out.println("TableSysLog.getQuery() Got query from flash!");
    if (query == null) {
        query = slc.getNewTableQuery();
        System.out.println("TableSysLog.getQuery() Created new query");
    }
    flash.put("Query", query);
    return query; }

The Links to go between pages are implemented with *p:commandLInk*s. I use Primefaces command link in AJAX mode so just the link gets processed when it is clicked. The action listener looks like this:

public void doNextPage(ActionEvent evt) {
    getQuery().doNextPage();
}

When it doesn't work I get the error message:

WARNING: JSF1095: The response was already committed by the time we tried to set the outgoing cookie for the flash.  Any values stored to the flash will not be available on the next request.

I found this thread when looking up this problem. When I turned of HTTP chunking as the article suggests, the error message went away but the problem remained.

Does anyone know what is going on and how this might be fixed?

© Stack Overflow or respective owner

Related posts about jsf-2.0

Related posts about primefaces