Hi Peter,
It's a shame they didn't implement flash attributes for Spring 3.1.x MVC. It
seems the only problem with that is that there's no way to get the binder to
also be used for the flash attributes. The underlying mechanism is still there
and usable by interacting with the FlashMap directly.
For setting flash attributes you'd do:
RequestContextUtils.getOutputFlashMap(request).put("flashMessage", "Some
message");
And for picking it up after the redirect you'd do:
String flashMessage = null;
Map<String, ?> inputFlashMap = RequestContextUtils.getInputFlashMap(request);
if (inputFlashMap != null)
flashMessage = (String) inputFlashMap.get("flashMessage");
I've experimented with adding support for it myself by extending the classes
and adding a custom WebArgumentResolver and it seems it can be done. With the
short-coming that a custom data binder used for the controller won't have
affect on the flash attributes as they are put into the FlashMap. But I doubt
this would be a problem for most users. Also, the only way I could found that
would let me use @ModelAttribute to get the flash attribute was overriding the
creation of data binders and substitute the attribute there. Clearly a hack but
if you don't mind it these classes could be of use to you.
I have attached the code to BOSSOM-167
Hope that help, Tobias
--
Context is everything:
http://forum.magnolia-cms.com/forum/thread.html?threadId=a4a17380-52b0-4ec0-9754-b01aee949c66
----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------