7

We are developing an app in which we have to support multiple browser tabs/windows. Our setup: MyFaces 2.1, Spring, Orchestra

By default the org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION is set to 20. This means that if you open 21 tabs in browser, then the page in the first tab stops working - no view state for given view.

The same will happen if you open 2 tabs and request 21 view updates (ie. Ajax events) in the second tab. Then a click in the first tab will generate the same exception.

Is there a way around this? For example, is it possible to bind the view cache to conversation scope?

jmj
  • 237,923
  • 42
  • 401
  • 438
DAN
  • 507
  • 1
  • 7
  • 16

1 Answers1

3

Set the view state saving method to client instead of server in web.xml.

<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
</context-param>

This way the entire view state will be saved (in serialized form, of course) in a hidden input field of the form instead of only the view state ID which refers the state in the session. This has the disadvantage that the page size may grow, but this should not be a major issue if you have partial view state saving turned on (which should be the default in JSF 2.0).

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Unfortunately we can't switch to client-side state saving. Isn't there a "server way" to solve it? – DAN Nov 26 '11 at 21:34
  • Why not? It's pretty cheap. Certainly if you also turn on GZIP in the server. The server way would be increasing the number of views in session. I however wonder if your application really requires that much of simultaneous views in the session. – BalusC Nov 27 '11 at 03:49
  • 1
    The simple case where client state saving is extremally expensive is access from mobile networks, where you pay for every MB. And when the state itself adds 100kb overload to almost every click... – Danubian Sailor Jan 18 '13 at 09:26