I am currently working with Spring 3.1.2 (webflow version 2.3.1) and I’m facing an older problem once again. The problem is creating a new object via Spring webflow. So what I’d like to do is following :
<set name="myBean.foo" value="new Bar()"
I did some research and found out it was a no-go. Now facing that same problem, I’m wondering if there are maybe some new facilities for this problem that I don’t know about, or a preferred alternative. In the past I used a static factory for this.
In addition to Alan J Liu’s response : the object needs to be initiated every time a certain transition is made (or every time a certain view is entered).
PS : springsource did not quite answer my question here. Thanks in advance!
The ‘value’ attribute accepts SpEL (http://static.springsource.org/spring/docs/3.0.x/reference/expressions.html), so you can use the ‘new’ operator, just make sure that you are using the fully-qualified class name. Finally, newly created objects are in flow-scope by default, but you can specify the desired scope explicitly, this is working for me: