We are using:
- JSF 1.2-1.2_07-b03-FCS
- JSTL 1_1-mr2 (special build)
- Java 1.6.0_22-b04
- Eclipse 3.6.0 (Helios)
- Tomcat 6.0.28 (needs to run also on Weblogic)
- IE 7.0.5730.13
- Firefox: 6.0
We have mainForm.jsp, filterForm.jsp, and externalForm.jsp views.
There is a button "Filter" on mainForm.jsp to transition to filterForm.jsp. It does that by a navigation rule:
<h:commandButton value="Filter" action="#{mainBean.filterData}" />
The mainBean.java code is:
public String filterData() {
    doStuff();
    return "filter";
}
This initially transitions correctly to filterForm.jsp. We can go back to the mainForm.jsp with the browser back button. We can do this repeatedly.
On mainForm.jsp we have a table (actually an ILog Gantt Chart, but we don't think that matters), with a "popup" menu on the chart bars. One of the menu options is to redirect to the externalForm.jsp.
Selecting the "redirect" triggers the following method in mainBean.java:
public void redirect(FacesMenuActionEvent event) {
    if (svr == null) {
        svr = new SetupURL(); // Simple code to set up the full URL
    }
    redirectUrl = svr.redirect(event);  // URL of externalForm.jsp
    svr.redirectData(redirectUrl);
}
This correctly works. The window transitions to externalForm.jsp.
If we press the browser back button on externalForm.jsp, we transition back to mainForm.jsp and things look OK.
If we then press the "Filter" button, the code does not execute the filterData() method, but instead it executes the redirect() method and we transition to the externalForm.jsp view, not the filterForm.jsp view.
Why does it do this and how do we force a call to filterData() instead?
******************************************************************************
BalusC - thank you for your solution.  With a few slight tweeks, it worked great.
The changes I made to web.xml are:
    <filter>
       <filter-name>noCacheFilter</filter-name>
       <filter-class>{my package name}.CacheControlFilter</filter-class>
    </filter>
    <filter-mapping>
       <filter-name>noCacheFilter</filter-name>
       <url-pattern>/faces/*</url-pattern>
    </filter-mapping>
Also, I found another solution:
faces-config.xml add:
    <lifecycle>
        <phase-listener id="nocache">{my package name}.
        CacheControlPhaseListener</phase-listener>
    </lifecycle>    
Create file CacheControlPhaseListener.java:
package {my package name};
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");
        // Stronger according to blog comment below that references HTTP spec
        response.addHeader("Cache-Control", "no-store");
        response.addHeader("Cache-Control", "must-revalidate");
        // some date in the past
        response.addHeader("Expires", "Mon, 8 Aug 2006 10:00:00 GMT");
    }
}
Both seem to work.
Thanks,
John
 
    