JSF: NUMBER_OF_VIEWS_IN_SESSION and the back button
I've got a memory problem in my application because of AJAX4JSF high memory consumption. So we have decided to set the NUMBER_OF_VIEWS_IN_SESSION to 1 and compromise the back button functionality.
However, after adding the following to the web.xml file, the back button still works.
<context-param>
<param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
<param-value>1</param-value>
</context-param>
I would like to understand: How the back button still works?!! I've read that setting the NUMBER_OF_VIEWS_IN_SESSION to 1 looses the browser back button functionality.
Thanks in advance for your开发者_JS百科 help.
I've read that setting the
NUMBER_OF_VIEWS_IN_SESSION
to 1 loses the browser back button functionality.
Either that article you're reading is babbling nonsense or you've misinterpreted the article. The back button's functionality can in no way be controlled from the server side on.
Perhaps the article meant the fact that you cannot submit the page which is been served from the browser cache by back button anymore because this would result in a ViewExpiredException
. You'd need to create a Filter
which adds response header to instruct the browser to not cache the page so that pressing the back button would fire a brand new GET request on the page so that you won't get a ViewExpiredException
anymore when submitting a form on that page.
As to the high memory consumption, I suspect that your problem is caused by something else. Perhaps you're just cobbling too many data in a view or session scoped bean. Read this thoroughly: Why JSF saves the state of UI components on server? Last, but not least, run a profiler before making assumptions.
精彩评论