开发者

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开发者_StackOverflow '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.


You can use the MyFaces Tomahawk 's <t:saveState> tag to save the so-called LOV in page 1.

If you use JSF2 , it seems that you can try view scope feature .

What is the View Scope ? View Scope has been introduced in JSF 2.0 and it's particularly useful when you are editing some objects while staying in the same page. In other words it's something broader then request but smaller then session, since this scope terminates if you navigate to other pages.

You can refer to http://www.mastertheboss.com/java-ee-16-articles/258-jsf-20-tutorial-on-jboss-as-part-1.html for the example of how to use view scope in JSF 2.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜