Hi all,
Using 3.0.0.RELEASE, SWF 2.0.8.RELEASE
Bottom line up front: how do I reference objects from various SWF scopes as a modelAttribute in a Spring <form:form>?
I have a simple web flow that uses a <var/> to create a domain object in flowScope:
From flow definition xml:
Code:<var name="flowScope.users" class="com..Users" /> <!-- A sample view state --> <view-state id="view-state-1" model="flowScope.users" > <transition on="save" to="saveUser"/> <transition on="success" to="view-state-2" /> <transition on="cancel" to="end-state" /> </view-state>
My views are apache tiles views using JSPX and Spring MVC <form:form> tags (this started life as a Roo app):
Everything works great if I do not declare the <var> I am using as a modelAttribute for the <form:form> into a specific SWF namespace (i.e. 'users'[works] vs. 'FlowScope.users'[does not work]), but as soon as declare the <var> as flowScope.users I have problems.Code:<form:form action="${form_url}" method="POST" ModelAttribute="flowScope.users"> .... </form:form>
If I do this (thinking that SWF scope resolution rules will apply):
I get the following runtime error when hitting the flow:Code:<form:form action="${form_url}" method="POST" modelAttribute="users">
If I try to be more specific and prefix the modelAttribute with a SWF namespace I get pretty much the same:Code:Attempting to handle [org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'view-state-1' of flow 'sampleflow'] with root cause [java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'users' available as request attribute] Rethrowing unhandled flow execution exception Unlocking conversation
<form:form action="${form_url}" method="POST" modelAttribute="flowScope.users">
Yields the similarly vexing:
What am I missing? Shouldn't I be able to declare an object at flowScope and let the user "work on it" through various stages of the flow?Code:Attempting to handle [org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'view-state-1' of flow 'sampleflow'] with root cause [java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'flowScope' available as request attribute] Rethrowing unhandled flow execution exception Unlocking conversation
Or do I have to copy the object to viewScope or flashScope every time and/or persist it at every step? (probably not)
Bottom line, how do I reference objects from various SWF scopes as a modelAttribute in a Spring <form:form>?
Thanks.


Reply With Quote
