@SessionAttributes doesn't work with tabbed browsing [SPR-4160] #8838
Comments
Juergen Hoeller commented This is by intention, actually, following the behavior of Spring's good old SimpleFormController. Handling multiple tabs individually in terms of their state in the server-side session would require a 'conversation' key to be sent for each form, with the attributes e.g. stored with that key as prefix in the server-side session. Standard views simply don't send such a conversation-identifying key. In other words, conversation handling requires some extra work. This can be achieved through a custom version of Spring's DefaultSessionAttributeStore, overriding the "getAttributeNameInSession" method accordingly, extracting the conversation key from a request parameter there. Such a custom SessionAttributeStore version can be specified as "sessionAttributeStore" on the AnnotationMethodHandlerAdapter (which you can simply include as an explicit bean definition in your DispatcherServlet context). That said - our general recommendation for such purposes is Spring Web Flow, which has sophisticated conversation handling out of the box. SWF 2.0 will fully support Spring 2.5's annotation controller style, so that In any case, I'll keep this issue open as an enhancement request. We at least need to point out this limitation as clearly as possible, and keep the documentation in sync with Spring Web Flow 2.0's evolution. Juergen |
Keith Donald commented Yes, this issue is still open at present. The conversation management facilities needed to do this currently reside in Web Flow 2.0. To add support for this capability yourself, you'd need to look into using Web Flow's ConversationManager facility in conjunction with the SessionAttributeStore extension point Juergen mentions. The Spring Framework and Web Flow teams will be working together to get this support added to the |
Marty Jones commented I have a intermediate solution for anyone who needs a solution until the official Spring version is released. Here is a link to the solution: http://forum.springsource.org/showthread.php?t=95016 |
Arturo Alfaro commented Thank's Marty |
Manuel Jordan commented With Spring 4 and 4.1.. some consideration in resolve this problem? Thank You. |
Juergen Hoeller commented There is no specific solution for this on the roadmap anymore. The given extension hooks allow for using custom conversation prefixes etc, and there are WebFlow and other conversation mechanisms for browser usage. Juergen |
Manuel Jordan commented Hi Juergen I see and understand this situation, but thinking in the community. Would be possible share this problem/situation in Spring Reference documentation and share your thoughts? I think is very important let know the developers this problem and how SWF and other options handle/resolve this. Kind Regards |
Paul Middelkoop opened SPR-4160 and commented
A
@SessionAttributes
value is stored in the session using the name provided to the annotation. This is wrong in my opinion. When I open the same page in two different tabs (so same session) my first session attribute is overridden.I'm not sure if their is a solution for this problem.
Affects: 2.5 final
Issue Links:
@Controller
model ("depends on")@SessionAttributes
not working as expected9 votes, 16 watchers
The text was updated successfully, but these errors were encountered: