Vinaya Tirikkovalluru wrote:
>
> Hi,
>
>
>
> I recently switched over to facelets.
>
> Now all my jsps are xhtmls
>
> How do I expire the page if the user clicks on browser back button?
>
>
>
> Any ideas?
>
Hi Vinaya,
I just did it via a Phase Listener. This would work on all JSF
implementations. The problem is though that due to a bug Firefox 3.0.x
ignore the cache settings. I saw that they consider it a major bug and they
also have a patch read with the last modified date of yesterday.
Here is the code:
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;
import org.apache.log4j.Logger;
public class NoBrowserCachePhaseListener implements PhaseListener {
public void afterPhase(PhaseEvent event) {
// Do nothing special
}
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.addHeader("Cache-Control", "no-store");
response.addHeader("Cache-Control", "must-revalidate");
response.addHeader("Expires", "0");
}
public PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}
}
You need to add this to your faces-config.xml:
<lifecycle>
<phase-listener>NoBrowserCachePhaseListener</phase-listener>
</lifecycle>
HTH,
Chris
--
View this message in context:
http://www.nabble.com/Facelets-Back-Button-tp20582987p20604555.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.