Managing webapp session data/controller flow for multiple tabs

后端 未结 4 979
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 07:57

I have a Java web application which stores some data in the session. The data in the session changes as the user interacts with the application (e.g. flow is managed by a co

相关标签:
4条回答
  • 2020-11-30 08:02

    This is usually done by assigning a windowId for each tab/window and passing it on each request. Jsf supports this via orchestra. Spring mvc will support it in the next version.

    I recently needed this for a simple case, so I implemented it myself. Took half an hour. However, my scope was very limited:

    • pass a windowId with each request, and return it back for the next request. The first time - generate it.
    • for any attribute you want to store in the session, put a Map<String, Object> where the key is the windowId
    0 讨论(0)
  • 2020-11-30 08:14

    This is exactly what Seam was created to handle. In Seam there's a concept called a Conversation which basically does exactly what you are explaining. Conversations are basically are a way to divide the Session into many pieces that can expire at some timeout. You can look at the source code for org.jboss.seam.core.Manager class to see how it's actually implemented and get inspired ;)

    0 讨论(0)
  • 2020-11-30 08:26

    Depending on the complexity of your application, you may want to investigate implementing tabs within your application. This gives you wholesale control over the flow, while still providing users with the functionality they want. I'd argue it's, bugwise, the most robust solution, since you won't have a dependency on the way the browser handles sessions, minimising the number of "known unknowns".

    Of course, there'll be potentially a large upfront cost to this, depending on how your application is structured. Without more information about your app, you're the best placed person to decide.

    0 讨论(0)
  • 2020-11-30 08:28

    You can also try to wrap your application inside Adobe Air

    And then limit your web application to be only accessable from this air. By doing this you dont need to consider the web browser fragmentation and their unique behaviour.

    0 讨论(0)
提交回复
热议问题