Back button issues with JSF and server side state saving

Posted by – October 27, 2008

For several months I tried to avoid this problem that only happens with server side state saving, but now I can’t run away anymore. Really sad.

I have a page that contains a dataList used to render a list of commandLinks, when I click on one of these commandLinks, the attached ActionListener gets called, but if I click on back button and then click on any other commandLink, the ActionListener attached to this component isn’t called, after several hours of debugging I discovered JSF are always trying to restore the current viewstate and not the viewstate related with the original version of my view.

JSF helped a lot on development of many projects, but now I’m really considering the use of Wicket on development of some search frontends that requires good back button support.

Share

4 Comments on Back button issues with JSF and server side state saving

  1. Rafael Ponte says:

    Hi Rogerio,

    It\’s possible to resolve this problem just increasing the number of views in session with context parameters bellow,
    - com.sun.faces.NUMBER_OF_VIEWS_IN_SESSION, lets you override the default of 15 top level (or root) views that are allowed to exist in a session;
    - com.sun.faces.NUMBER_OF_LOGICAL_VIEWS_IN_SESSION, lets you override the default of 15 logical views that may exist per root view in a session, where a logical view is a subview of a top level view.

    However the use of server memory increases too, well, it\’s a trade-off :twisted:
    Take care buddy!

  2. Rafael Ponte says:

    Ops, the context init parameters has changed during the releases of Mojarra, you may see more about them here,
    http://wiki.glassfish.java.net/Wiki.jsp?page=JavaServerFacesRI#section-JavaServerFacesRI-WhatContextParametersAreAvailableAndWhatDoTheyDo

    :)

  3. Joey says:

    Glad to know I\’m not the only one suffering from this problem. Did you find a solution?

    I\’ve messed around with a bunch of different parameters in web.xml including the number of views in session with no results. Oddly, I read on another forum that you should decrease the number of views to force it to refresh and fix this problem??? I\’ve given up trying to make sense of how JSF\’s innards work.

    Thanks.

  4. rogerio says:

    To solve this problem you only need adopt a good pratice, use t:saveState or rich:keepAlive to save only specific properties on you bean and not the entire bean.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>