tags:

views:

35

answers:

2

I have a backing bean (say MyPageBean) with request scope, but it seems to be in session because, navigating my application, when I visit the page myPage, I always get the same instance. I'm using JSF 1.2, IceFaces 1.8.2 and JBoss 5.1.0

A: 

Isn't it just your webbrowser or proxy which is aggressively caching the webpages?

Create a Filter which does the following in doFilter() method to instruct the client to not cache the HTTP response:

HttpServletResponse hsr = (HttpServletResponse) response;
hsr.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
hsr.setHeader("Pragma", "no-cache"); // HTTP 1.0.
hsr.setDateHeader("Expires", 0); // Proxies.
chain.doFilter(request, response);

and map it in web.xml like follows:

<filter>
    <filter-name>cacheFilter</filter-name>
    <filter-class>com.example.CacheFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>cacheFilter</filter-name>
    <servlet-name>facesServlet</servlet-name>
</filter-mapping>

assuming that you've mapped the FacesServlet instance on <servlet-name> of facesServlet.

BalusC
BalusC, thanks for your answer.
Massimo
But your solution does not work.
Massimo
How did you confirm that the bean which the page is using is really in the request scope? How did you confirm that you're retrieving exactly the same instance everytime? Did you do some poor man's systemoutprintln's? Which and where? Or did you run a debugger with a breakpoint on bean's constructor? Did you determine the `#{requestScope}` and `#{sessionScope}`? Etcetera.
BalusC
A: 

In ICEFaces request scope extends across partial submits. So if your application never refreshes the whole page, and uses only partial submits, you may encounter this.
Not using partial submit in the navigation should solve your problem.

Adam