« Return to Thread: [Fwd: back button - fields remain empty when they should be populated by session values?]

[Fwd: back button - fields remain empty when they should be populated by session values?]

by Chris Fleischmann :: Rate this Message:

Reply to Author | View in Thread

Fixed, I introduced the following phase listener, courtesy of http://turbomanage.wordpress.com/2006/08/08/disable-browser-caching-in-jsf/:

----

import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
import javax.servlet.http.HttpServletResponse;

public class CacheControlPhaseListener implements PhaseListener {

    public PhaseId getPhaseId() {
        return PhaseId.RENDER_RESPONSE;
    }

    public void afterPhase(PhaseEvent event) {
    }

    public void beforePhase(PhaseEvent event) {
        FacesContext facesContext = event.getFacesContext();
        HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();

        response.addHeader("Pragma", "no-cache");
        response.addHeader("Cache-Control", "no-cache");
        response.setHeader("Cache-Control", "no-store");
        response.addHeader("Cache-Control", "must-revalidate");
    }
}

and put the following lines in the faces-config.xml file.

<lifecycle >
      <phase-listener><PACKAGE TO GET TO>.CacheControlPhaseListener</phase-listener>
</lifecycle>



NetBeans 6.0.1
Visual JSF 1.0.3.

Folks, Im wondering if you can help me out here... I have a 2 JSF pages, thef irst page has a series of textfields and a submit button all bound to session properties... the button submits the form-data and moves on to page 2. Now if i click the browsers back button (going back to page 1), the text fields are empty, however if i click the browsers "reload" button all of the textfields are re-populated with their respective session values as I hope they would...

Is there a way to fix this?

I have also tried adding a CacheControlFilter specifying the following properties, to no avail:

hres.addHeader("Cache-Control", "no-cache");
hres.setHeader("Cache-Control", "no-store");
hres.addHeader("Cache-Control", "must-revalidate");
hres.addHeader("Pragma", "no-cache");

Am I missing something?

Thanks for your help,



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: [Fwd: back button - fields remain empty when they should be populated by session values?]

LightInTheBox - Buy quality products at wholesale price!