-
1. Re: Datatable empty after function call with redirect?
healeyb Sep 19, 2012 3:20 PM (in response to fastridingzebra)Is the browser caching the page? try running with a decent browser such as chrome or firefox and see if the page is being served
from the cache, using the developer tools network tab or firebug.
The response headers in a .jsf page need to be set so that the page isn't cached which you'd do in a servlet filter:
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setDateHeader("Expires", 0); // Already expired
sharp eyed readers will spot BalusCs original comments! you'd also typically setup response headers to ensure that you do
cache your static resources such as css and images.
This is one of those things with JSF that aren't all that immediately obvious and can take a lot of time to get right. I probably spent
3-4 weeks getting a cache filter exactly right.
http://stackoverflow.com/tags/servlet-filters/info
Regards,
Brendan.
p.s. the other thing I was going to ask is which jsf version are you using? with JSF 2 the action method can just
return "
combinationSelected.jsf
?faces-redirect=true"; - this will do a post-redirect-get and the URL will show thecorrect value rather than lagging a step behind.
Freelance Java Enterprise Developer
JSF Richfaces Ajax Java 6/7 (scjp) EE 6 HTML CSS JavaScript jQuery MySQL JPA Hibernate Eclipselink
Spring Oracle SQL JPQL Sybase EJB CDI Glassfish Apache JAX-RS Primefaces UNIX Paypal and more..
-
2. Re: Datatable empty after function call with redirect?
fastridingzebra Sep 20, 2012 3:55 AM (in response to healeyb)Hy Brendan,
thx for your suggestions. I looked into the cache thing but even when I manually emptied the cache before going back to "example.jsf"
the problem remained.
Here is how I solved it (maybe someone can explain to me why this is working and how ... would be great!)
Instead of creating a request by using commandlink I used:
<a4j:ajax event="click" listener="#{formBean.selectCombination}" />
So when using ajax instead of a request when I go back now me datatable still has all the content.
Remember my bean is session scope... so I thought it would not make any difference if I use ajax or request in my special case.
What do I miss here?
Thx