0

I have a CDI application using Deltaspike which uses the incredibly useful @WindowScoped annotation to support multiple tabs. The scenario of the application is as follows:

  1. User selects an item from a list and clicks 'Edit'.
  2. The user authenticates against object.
  3. The id of the object being edited and the username of the authenticated user is stored against the window scope and is available to all the pages within the edit section of the system.
  4. When the user has finished accessing this object they click finish and their session with this object is closed (@WindowScoped bean wiped out).

If the user opens a new tab and then selects a new object to edit then everything works perfectly, since the ID and authentication details are stored against a new @WindowScoped object.

However, since there are multiple edit pages the user is also able to right click and open the link in a new tab. This then fails because the new @WindowScoped bean doesn't know anything about the context in which it was created (basically the object ID and username of the previous session).

Is there a way using @WindowScoped to access the previous window scoped object? Or is there a common way to share information between window scoped beans?

Thanks for any advice!

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
StuPointerException
  • 7,117
  • 5
  • 29
  • 54
  • How exactly is `@ViewScoped` insufficient? Is it because its `@PreDestroy` is not invoked at expected moments? Or is it because you're technically not staying in the same view (and thus navigation is not by ajax and conditional rendering or dynamic include)? – BalusC Feb 05 '16 at 11:09
  • There are multiple views and multiple `@ViewScoped` beans backing components within the edit section of the system. I'm using '@WindowScoped' as a session for the current user (injecting it into the security phase listeners and also the `@ViewScoped` beans). I was previously using `@SessionScoped` which had its own problems! – StuPointerException Feb 05 '16 at 11:15
  • Ah right, I got confused with ICEfaces `@WindowScoped`. The DeltaSpike one is thus like CDI's own `@ConversationScoped`? Nevermind then. No, you can't solve this problem without merging the views into one (with ajax rendering and all) so you can use ICEfaces `@WindowScoped` or OmniFaces `@ViewScoped` which immediately destroys bean on window unload event. – BalusC Feb 05 '16 at 11:18
  • Thanks for the information, I'll take a look into alternative approaches! – StuPointerException Feb 05 '16 at 11:23

0 Answers0