0

I need to keep some state in either the server or client to allow my users to continue searching on a keyword in a search results page. (It's a basic search engine for some products with a google like first page, and search results second page.)

I tried the recommended solution:

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

and combined it with

session.setMaxInactiveInterval(10);

for testing. But it seems like the state is not saved, and on the next POST click the keywords and products in my SessionScoped beans are lost.

Is there a solution? A workaround? It's really embarrassing to have a your session expired error message displayed to users, who aren't even required to login.

Eddy
  • 3,533
  • 13
  • 59
  • 89

1 Answers1

1

Session scoped beans are tied to HTTP session. When it expires, then, well, they will be recreated.

You perhaps meant to use a view scoped bean. It's not tied to the HTTP session, but to JSF view state. It will never expire when you use client side state saving, as you actually have configured.

An alternative is to just go stateless and simply use a request scoped bean (with state retained via plain HTML hidden fields in the form; basically you're taking over javax.faces.ViewState's job).

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555