Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@SessionAttributes doesn't work with tabbed browsing [SPR-4160] #8838

Closed
spring-projects-issues opened this issue Nov 23, 2007 · 7 comments
Closed

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Nov 23, 2007

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:

  • SWF-1009 Add support for conversations with the Spring MVC @Controller model ("depends on")
  • #19255 @SessionAttributes not working as expected
  • #8691 Add support for outputting a 'dialog key', like a Web Flow execution key, when using the form tag.
  • #8337 AbstractWizardFormController views do not send current page number by default

9 votes, 16 watchers

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 24, 2007

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 @SessionAttributes marked attributes will transparently be stored into a conversational session instead of the global servlet session. Spring's core MVC mainly serves as a runtime for stateless request processing, with SWF providing full-fledged UI state management on top.

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

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jan 5, 2009

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 @Controller programming model for Spring 3.0 and Spring Web Flow 3.0.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 26, 2010

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

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 17, 2010

Arturo Alfaro commented

Thank's Marty

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 18, 2014

Manuel Jordan commented

With Spring 4 and 4.1.. some consideration in resolve this problem?

Thank You.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 22, 2015

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

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 24, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants