Search code examples
sessionjsficefaces

Could form values be preserved without using session scope?


I have two pages having page one got datatable and a few LOV's.

When I navigate from page one to page two, could the values in LOV's and datatable pagination be preserved when I navigate back to page one from page two without using session scope?

If so how can I do this?

Update 1

I could see the following log when I run my application. May be I am missing something obvious!!

4234 [ApplicationServerThread-0] INFO  org.apache.myfaces.shared_tomahawk.config.MyfacesConfig  - No context init parameter 'org.apache.myfaces.PRETTY_HTML' found, using default value true
4234 [ApplicationServerThread-0] INFO  org.apache.myfaces.shared_tomahawk.config.MyfacesConfig  - No context init parameter 'org.apache.myfaces.ALLOW_JAVASCRIPT' found, using default value true
4234 [ApplicationServerThread-0] INFO  org.apache.myfaces.shared_tomahawk.config.MyfacesConfig  - No context init parameter 'org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS' found, using default value true
4234 [ApplicationServerThread-0] INFO  org.apache.myfaces.shared_tomahawk.config.MyfacesConfig  - No context init parameter 'org.apache.myfaces.RENDER_VIEWSTATE_ID' found, using default value true
4234 [ApplicationServerThread-0] INFO  org.apache.myfaces.shared_tomahawk.config.MyfacesConfig  - No context init parameter 'org.apache.myfaces.STRICT_XHTML_LINKS' found, using default value true
4234 [ApplicationServerThread-0] INFO  org.apache.myfaces.shared_tomahawk.config.MyfacesConfig  - No context init parameter 'org.apache.myfaces.CONFIG_REFRESH_PERIOD' found, using default value 2
4234 [ApplicationServerThread-0] INFO  org.apache.myfaces.shared_tomahawk.config.MyfacesConfig  - No context init parameter 'org.apache.myfaces.DETECT_JAVASCRIPT' found, using default value false
4234 [ApplicationServerThread-0] INFO  org.apache.myfaces.shared_tomahawk.config.MyfacesConfig  - No context init parameter 'org.apache.myfaces.AUTO_SCROLL' found, using default value false
4234 [ApplicationServerThread-0] INFO  org.apache.myfaces.shared_tomahawk.config.MyfacesConfig  - No context init parameter 'org.apache.myfaces.ADD_RESOURCE_CLASS' found, using default value org.apache.myfaces.renderkit.html.util.DefaultAddResource
4234 [ApplicationServerThread-0] INFO  org.apache.myfaces.shared_tomahawk.config.MyfacesConfig  - No context init parameter 'org.apache.myfaces.RESOURCE_VIRTUAL_PATH' found, using default value /faces/myFacesExtensionResource
4234 [ApplicationServerThread-0] INFO  org.apache.myfaces.shared_tomahawk.config.MyfacesConfig  - No context init parameter 'org.apache.myfaces.CHECK_EXTENSIONS_FILTER' found, using default value true
4234 [ApplicationServerThread-0] INFO  org.apache.myfaces.shared_tomahawk.config.MyfacesConfig  - Starting up Tomahawk on the RI-JSF-Implementation.

Solution

  • The issue I had with preserving form values after navigating back(request scope) is resolved using FullRedirectTrackPolicy.

    Add the following in web.xml and add tomahawk-sandbox.jar to your project.

    <context-param>
            <param-name>org.apache.myfaces.redirectTracker.POLICY</param-name>
            <param-value>org.apache.myfaces.custom.redirectTracker.policy.FullRedirectTrackPolicy</param-value>
        </context-param>
    

    More information is available here

    I couldn't resolve without redirect rules in faces-config.xml, there are a few errors.

    Thanks @BalusC for providing information about t:saveState and to @user339637

    Regards