While waiting for FlashScope to be integrated into Spring 3.1 (it's scheduled for this release anyways), I came across this bug posting, which allowed me to incorporate a loose version of what should be available once 3.1 comes out.
My issue is that I seem to be unable to bind to values which are in Flash Scope. So for instance in my model I have the following code:
ModelAndView mav = new ModelAndView(someInjectedRedirectPage);
//Processing
mav.addObject("flashScope.someVar", someObject);
In my UI, using Velocity, I than attempt to bind to this object in the following manner:
##This is a velocimacro for those not familiar with velocity.
##It is basically like setting a path on a field utilizing the
##spring tag lib (e.x. <form:text path="flashScope")
#springBind("flashScope")
However when I attempt to use that binding, I get the following exception:
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'flashScope' available as request attribute
at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141)
at org.springframework.web.servlet.support.RequestContext.getBindStatus(RequestContext.java:720)bean name 'flashScope' available as request attribute...
However In my logs, I can clearly state that it's been added to the request. I can also do the following:
$flashScope.someVar.someProperty #The value prints fine this way.
Is there anyway to bind to a Map value (which isn't on a backing command object, but rather just on the request)?
Note if Do the following:
Map<String, String> map = new HashMap <String, String>();
map.put("key", "value");
mav.addObject("map", map);
I'm still not able to bind to the map...
Is this behavior I can modify by extending the WebBindingInitializer? Would simply wrapping the FlashScopeMap into another object rectify the problem?