views:

1415

answers:

2

Dear all,

We have the following problem...

Application's environment:

JSF, Richfaces, a4J

Consider having the following scenario:

  • The user logs into the system
  • The user navigates to a new page which consists of an a4j form containing a4j components, the user fills into the form but doesn't submit.
  • The user opens a new Tab and opens the same URL and fill in the new form with new data
  • The user returns to his first Tab and submits the information (Note: All beans are defined are session scope)

Result:

The submitted information is the information from the second Tab but submitted from the first Tab, which is expected as long as the beans are defined as session scope.

Problem:

We need to get the behavior of a request scope (i.e: dealing with new tab as a new request although the bean is defined as a session scope).

Notes:

When defining the bean scope as a request scope the partial Ajax response from individual components in the same form, resets the other components since they are not submitted yet.

Any suggestions ?

--

Thanks so much

+1  A: 

This is a well known problem for Web applications.

Of course you can try to solve this problem using more custom code but my quick suggestion is to use the seam framework which solves exactly this.

Seam is a superset of JSF and introduces a new conversation scope for beans that does exactly what you want.

Seam supports richfaces natively (both are projects of JBoss/Redhat) so you should not expect any problems with integration.

kazanaki
A: 

What is the reason the bean needs to be in session scope ?

If this is only to get ajax functionality then you can change the bean to request and use the a4j:keepAlive tag.

a4j:keepAlive extends the live cycle for the request scope bean, your bean instance then acts like it is in session scope for ajax requests. When the user opens two of the same page they are using two different bean instances.

Mark Robinson