All entries for Friday 05 May 2006
May 05, 2006
Spring Web Flow RC1.0 – mapping comments
Writing about web page http://www.springframework.org/documentation
So I have downloaded SWF RC1.0 and doing the upgrade. This post if really just for me to keep track of things :)
Input mapping when calling a subflow
The source must be an expression, i.e. ${model.someProperty} whereas the target must be text:<mapping source="${model.uploadedFiles}" target="uploadedFiles"/>
Output mapping when calling a subflow
The source must be text i.e. someProperty whereas the target must also be text, but qualify the scope:<mapping source="emptyFiles" target="flowScope.emptyFiles"/>
Input mapping for the subflow itself
The subflow must now explicitly slurp the inputs.The source must be text i.e. someProperty whereas the target must also be text, but qualify the scope:
<mapping source="uploadedFiles" target="flowScope.uploadedFiles"/>
Output mapping for the subflow itself (i.e. end state)
The subflow must now explicitly export the results that the calling flow can slurp.The source must be an expression i.e. ${flowScope.someProperty} whereas the target must be text:
<mapping source="${model.emptyFiles}" target="emptyFiles"/>
Essentially, when a subflow starts, the calling flow exports bits of its context into a generic map, so source is an expression, target is the key in the map. The subflow (when it starts) can slurp from that generic map using the known key, so source is the key, target is where in the subflow context it must be placed (as plain text, not expression).
When the subflow ends, it exports bits of its context using the same rationale; source is an expression, target is the key in the generic map. The calling flow can then slurp from that generic map; source is key, target is plain text description of where it is placed.
example:
<flow ...> <subflow-state ...> <attribute-mapper> <input-mapper> <mapping source="${model.uploadedFiles}" target="uploadedFiles"/> </input-mapper> <output-mapper> <mapping source="emptyFiles" target="flowScope.emptyFiles"/> <mapping source="invalidFileNames" target="flowScope.invalidFileNames"/> <mapping source="invalidFileTypes" target="flowScope.invalidFileTypes"/> <mapping source="duplicateFiles" target="flowScope.duplicateFiles"/> <mapping source="createdFiles" target="flowScope.createdFiles"/> </output-mapper> </attribute-mapper> </subflow-state> </flow>
...
Note: nothing in here is the definitive way; but it does work :)