– form model attributes stored in a session – SessionAttributeStore SPI in the background @Controller @SessionAttributes("book") public class MyController { @RequestMapping("/edit") public String editBook(@ModelAttribute("book") Book book) { … } }
"conversation" @Controller @SessionAttributes("book") public class MyController { @RequestMapping("/store") public String storeBook(@ModelAttribute("book") Book book, SessionStatus sessionStatus) { … sessionStatus.setComplete(); } }
– lots of temporary attributes stored in the session • may or may not get cleaned up • potential conflicts in attribute naming • Window isolation – HttpSession identified by cookie • shared among browser windows – UI flow is independent per browser window • e.g. opening same registration form in two windows • independent form state per window • switching back and forth between concurrent windows
to be removed from the session once their form has been completed • e.g. what if nobody calls sessionStatus.setComplete() – compare JSF 2.0's view scope • Short-term model state to survive redirects – "flash" scope (also called "click" scope) • actually not a true scope: rather a "flash map" – currently done through temporary storage in session • involves a window isolation problem too – compare JSF 2.0's flash scope
scope – probably to be called "window session" – basically an isolated version of a standard session • effectively separated attributes in the HttpSession • Available for bean scoping through scope="windowSession" – as a direct alternative to scope="session" • Window-based Spring MVC session attributes – @SessionAttributes can be globally configured to point to window sessions • SessionAttributeStore backed by window scope
a window – browser requests do not indicate originating window – checking the window name using JavaScript – detecting when a window has been cloned – on-close event to end current window's scope • Problem no. 2: propagating a window id – can't use cookies – need to pass along window id as part of the URL – decorating response.encodeURL • encoding ";window=xxx" element into path • similar to jsessionid when cookies are deactivated
– not demarcated by implicit technical concerns like the lifecycle of a browser window – instead, explicitly demarcated by the user • dedicated begin and end calls • Available for bean scoping through scope="conversation" – particularly useful in a JSF environment • where form-backing objects are usually managed beans – less important for Spring MVC • where form-backing model objects are subject to special MVC management
by the user, through API or annotations • Conversation interface • @BeginConversation, @EndConversation on methods – associating a conversation with the web request • propagating the current conversation id along with the current browser window • Conversations can be nested – similar to transactions • sub-conversations with early cleanup of sub-state – for advanced cases only • we have yet to figure out how far to go there…
flash concept – for Spring MVC • programmatic flash map access • model attributes to be automatically stored in flash map in case of a redirect – transparent model exposure between forwarded view and redirect view • flash map to be cleared once it has been read in a follow-up request – for JSF • access to JSF 2.0 flash scope • probably nothing special to come from Spring – standard JSF externalContext.getFlash() sufficient
2.0's view scope – for bean scoping through scope="view" • or @Scope("view") – only in JSF environments • strictly following JSF 2.0 view scope semantics • for compatibility with JSF managed bean facility • Not applicable to Spring MVC – no strong concept of a view instance and postbacks to that view in an MVC world – similar behavior achievable through session attributes and SessionStatus handling
2010 – including basic window and conversation management capabilities for Spring MVC • Spring Framework 3.1 M2 – July/August 2010 – complete conversation management capabilities for Spring MVC and JSF • Spring Framework 3.1 RC1 – expected for September 2010 – depending on feedback