Home:ALL Converter>Flash scope objects are getting lost

Flash scope objects are getting lost

Ask Time:2012-09-22T05:35:28         Author:AlanObject

Json Formatter

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:commandLInks. 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?

UPDATE:

In working with this problem I believe I have uncovered a bug in how the cookie that is used to store the flash object. The cookie it stores is named csfcfc, and the path parameter to the cookie is the root of my application, in my case "/A/".

However when it fails, I get a second csfcfc cookie, this time with the path parameter as "/A//". My working theory is that the cookie generator is sometimes adding an extra "/" to the path parameter, which means that the cookie is not seen on the next request even though the browser sent it.

It is notable that this happens very intermittently. I do NOT always get the JSF1095 message but I do get the extra cookie every time I looked.

I don't know if this is a Mojarra bug or a Glassfish bug, but I am adding the Mojarra tag to this post. I am not familiar with the bug data bases for those pro.ducts, but could someone here comment on what the next step should be?

I would appreciate any suggestions for a work around

Author:AlanObject,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12538483/flash-scope-objects-are-getting-lost
yy