When javax.faces.STATE_SAVING_METHOD is set to server, view state of the each page is saved in session map. If I am already in some view, and if I enter a url in browser (GET request) to the same page, a new view will be created. Now I want to delete the existing view. What is the best way and place, to clean up a particular earlier view with a new GET request, if I have the associated ViewId included in the get request path or as a GET request parameter. Thank you very much for your help.
Asked
Active
Viewed 830 times
0
-
Usually you control that via the Scope of your managed beans: application-, session-, page-, view-, request-scope (hopefully, I didn't forget any). Is your managed bean in session scope? – L-Ray Dec 06 '13 at 10:55
-
bean is jsf2 view scope – user3073999 Dec 06 '13 at 11:19
1 Answers
0
You can't. At least not by standard API means. Just let it expire.
If you worry about the memory usage because of a low memory footprint on target server and you intend to use JSF in stateless mode, and you're using Mojarra 2.1.19 or newer, just use
<f:view transient="true">
This way JSF won't save the view state at all. Keep in mind that the logical consequence is that you can't use the view scope anymore. The view scoped beans will behave like request scoped beans.
An alternative is to lower the default amount of (logical) views in session. See also com.sun.faces.numberOfViewsInSession vs com.sun.faces.numberOfLogicalViews for the exact working.
-
Yes, the problem is with memory usage, and I am using Myfaces-2.1. My app is to support multiple tabs / windows, using org.apache.myfaces.NUMBER_OF_SEQUENTIAL_VIEWS_IN_SESSION == 1, I get my earlier view cleared with Post/PRG requests. But browser back/forward or reload are GET requests and these views get piled up filling the default (20 views) and end up getting expiry in least used window / tab. Please advice/guide, if there is any reliable way to programmatically delete a view with viewid although it is not a standard API means. Thank you again. – user3073999 Dec 06 '13 at 11:51
-
-
That was the option I had thought of yesterday. Let me explore then, thank you. – user3073999 Dec 06 '13 at 12:04