How to keep JSF flash scope parameters after an ajax request on the page?

523 Views Asked by At

I am able to keep the flash variable for a page reload with the

FacesContext.getCurrentInstance().getExternalContext().getFlash().keep("someVar");

But any postback to the page cause me to lose the flash variable. I've tried putting on a preRenderView event listener and checking postbacks.

if(FacesContext.getCurrentInstance().isPostback())
FacesContext.getCurrentInstance().getExternalContext().getFlash().keep("someVar");

But this time I am getting this error and losing the flash variable

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.

Actually what I am trying to achieve is to use Post-Redirect-Get pattern and persist the page data on manual reload of the page(user hitting F5).I am using Mojorra 2.2.8

0

There are 0 best solutions below