PDA

View Full Version : output-mapper in RC1


Bubba Puryear
Apr 13th, 2006, 05:25 PM
Perhaps I'm being dense, but I can not seem to get an output-mapper to work for a subflow that I've got. Here's a parent flow:


<flow start-state="start">
<action-state id="start">
<action bean="formAction" method="setupForm"/>
<transition on="success" to="edit-construct-cassettes-subflow"/>
<transition on="error" to="finish"/>
</action-state>

<subflow-state id="edit-construct-cassettes-subflow" flow="edit-construct-cassettes-subflow">
<attribute-mapper>
<input-mapper>
<mapping source="${flowScope.construct}" target="construct"/>
</input-mapper>
<output-mapper>
<mapping source="construct" target="construct"/>
</output-mapper>
</attribute-mapper>
<transition on="finish" to="saveConstruct"/>
<transition on="cancel" to="finish"/>
</subflow-state>

<action-state id="saveConstruct">
<action bean="formAction" method="saveConstruct"/>
<transition on="success" to="finish"/>
<transition on="error" to="edit-construct-cassettes-subflow"/>
</action-state>

<end-state id="finish" view="externalRedirect:${externalContext.contextPath}/app/view/construct.html?pk=${flowScope.construct.pk}"/>

<import resource="edit-cassette-flow-context.xml"/>
</flow>


and here's the subflow, just for reference sake:

<flow start-state="editConstructCassettes">

<view-state id="editConstructCassettes" view="qc/construct/editCassettes">
<entry-actions>
<action bean="formAction" method="setupReferenceData"/>
</entry-actions>
<transition on="submit" to="finish">
<action bean="formAction" method="bindAndValidate"/>
</transition>
<transition on="delete" to="deleteCassette"/>
<transition on="complement" to="complementCassette"/>
<transition on="addCassette" to="addCassette">
<action bean="formAction" method="bind"/>
</transition>
<transition on="cancel" to="cancel"/>
</view-state>

<action-state id="addCassette">
<action bean="formAction" method="addCassette"/>
<transition on="success" to="editConstructCassettes"/>
<transition on="error" to="editConstructCassettes"/>
</action-state>

<action-state id="complementCassette">
<action bean="formAction" method="complement"/>
<transition on="success" to="editConstructCassettes"/>
<transition on="error" to="editConstructCassettes"/>
</action-state>

<action-state id="deleteCassette">
<action bean="formAction" method="delete"/>
<transition on="success" to="editConstructCassettes"/>
<transition on="error" to="editConstructCassettes"/>
</action-state>

<end-state id="cancel">
<output-attribute name="construct"/>
</end-state>

<end-state id="finish" view="externalRedirect:${externalContext.contextPath}/app/view/construct.html?pk=${flowScope.construct.pk}">
<output-attribute name="construct"/>
</end-state>

<import resource="edit-cassette-flow-context.xml"/>
</flow>


Now, the input-mapper seems to work well enough -- I get to my view. But when I submit, I get this:

ERROR: Servlet.service() for servlet neogenie threw exception [[neogenie]] <2006-04-13 17:10:18,684>
ognl.NoSuchPropertyException: org.springframework.webflow.execution.impl.FlowExe cutionControlContextImpl.construct
at ognl.ObjectPropertyAccessor.setProperty(ObjectProp ertyAccessor.java:133)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1629 )
at ognl.ASTProperty.setValueBody(ASTProperty.java:105 )
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.ja va:177)
at ognl.SimpleNode.setValue(SimpleNode.java:246)
at ognl.Ognl.setValue(Ognl.java:476)
at org.springframework.binding.expression.support.Ogn lExpression.setValue(OgnlExpression.java:73)
at org.springframework.binding.mapping.Mapping.map(Ma pping.java:89)
at org.springframework.binding.mapping.DefaultAttribu teMapper.map(DefaultAttributeMapper.java:77)
at org.springframework.webflow.support.AbstractFlowAt tributeMapper.mapSubflowOutput(AbstractFlowAttribu teMapper.java:60)
at org.springframework.webflow.SubflowState.mapSubflo wOutput(SubflowState.java:158)
at org.springframework.webflow.SubflowState.onEvent(S ubflowState.java:147)
at org.springframework.webflow.Flow.onEvent(Flow.java :630)
at ...


Am I missing something obvious or not finding the right documentation to steer me where I need to go? Thanks.

davidv
Apr 13th, 2006, 10:00 PM
This is all assuming you are using the latest snapshot nightly rc1 (>= build 12) since this has all changed in that release ... imho

To your primary question first:

I think the output-mapper mapping in your parent subflow-state should have target=flowScope.construct

(Just like you use that as the source in the input-mapper).

But I have another question for you:

Are you sure the input-mapping is really working ? Does is work if you use different names for the properties in each flow (ie not 'construct' for both parent and sub flow ) ?

Seems to me you are missing an opening flow level input-mapping in your subflow. Since rc1-build.12 I have found that I have to match each <input-mapper> mapping from the parent flow <subflow-state> with an explicit <input-mapper> mapping at the start of the called sub-flow. Kind of like formally defining the variables that a sub-flow is going to accept.

Refer to Keith's posting: http://forum.springframework.org/showpost.php?p=57387&postcount=1

* Refined the semantics of flow input attribute mapping. All input attributes passed into a flow
by a caller must now be explictly mapped by the flow. To achieve this each Flow can be configured
with an inputMapper; see Flow.setInputMapper and Flow.start.

Keith Donald
Apr 13th, 2006, 11:39 PM
You are correct David.

The output mapper mapping target should be "flowScope.construct" -- a instruction to map the "construct" subflow output attribute to the "construct" property in parent "flow scope".

Also yes, input now made available to a flow spawned as a subflow must be explicitly mapped by that flow using its <input-mapper/>. This makes it very clear what input the flow will accept, and also makes it possible for the flow to be reused as both a subflow and top-level flow.

Keith

Bubba Puryear
Apr 14th, 2006, 05:09 PM
Ah ha. Thanks on both points David and Keith. Those issues are now cleared up.

I'm running into some other troubles, but I chew on them a bit and if I can't solve them I'll post another thread. Thanks!

Bubba Puryear
Apr 14th, 2006, 05:11 PM
Oh and yes - I'm using a nightly build of rc1 after build 12. spring-webflow-1.0-rc1-20060410002028, to be exact.