Skip to main content

JSF Issue

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2011-09-05


My first post here so please bare with me. I have a web application that uses JSF components. One of the pages is a details page and this is made-up of a number of those components. Users can open mulriple instances of this page.

I have the following probklem which I would appreciate your help with.

  1. User opens window (A)
  2. User opens window (B)
  3. User enters data in window (A) and submits
  4. User refreshes window (B)
  5. Data entered in window (A) appears in window (B)

Is it possible that the JSF components used for window (A) are also used by window (B)? If this is the case, how can I prevent this from happening?



Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2011-03-28

Hello Patrick, you will have a backing bean annotated with either @ManagedBean or @Named, and
this will have a scope. I would guess that you are using @SessionScoped, and what you are seeing
is data shared by two browser windows that are part of the same session.
To avoid this use @RequestScoped. Or, if you're using ajax functionality either explicitly with f:ajax
or implicitly because you're using an ajax enabled component library like richfaces, icefaces, then
you'd be better using @ViewScoped.
If your bean is annotated with @Named then you're using CDI, and this provides the conversation
scope @ConversationScoped which supports the concept of maintaining state on a per browser
window basis. I've never really figured out conversation scope, you can start and end conversations
and you have to think about when to perform these actions and I've never gelled with this.
Although a more advanced topic the scopes specified by the JSF specification are more limited
than perhaps they could be, but happily you can download MyFaces CODI which provides the very
useful @ViewAccessScoped scope (you don't have to be using MyFaces JSF to use this), a much
easier to use conversation scope, conversation scope groups and other stuff.