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 :)


- 5 comments by 0 or more people Not publicly viewable

  1. Seth

    Nice post, was looking how to do this myself and couldn't figure it out until reading this. Thanks.

    16 May 2006, 05:16

  2. Alain

    Really useful! Thanks.

    11 Jul 2006, 22:24

  3. Michael Waldvogel

    Thanks for that awesome article!
    Until reading this article I just did not realize that there must be a mapping on both sides, so to speak in the parent flow AND the subflow.

    18 Nov 2006, 06:17

  4. Peter Hamlen

    Really useful! Thanks!

    From some other research, I’ve found that the mapping is handled by the FlowAttributeMapper class :
    http://static.springframework.org/spring-webflow/docs/1.0.x/api/org/springframework/webflow/engine/FlowAttributeMapper.html

    Also, you don’t have to put the source as an expression, although that definitely works – I’ve had success referring using things like:
    <end-state id=”save”>
    <output-mapper><mapping source=”flowScope.currentFormObject.parseReport” target=”parseReport”/></output-mapper>
    </end-state>

    (This passes the parseReport from the currentFormObject out to the calling flow.)

    Thanks for writing your article. It really helped!
    -Peter

    12 Dec 2006, 21:43

  5. Sandeep

    Very very well written. Cant thank enough.

    23 Feb 2007, 04:19


Add a comment

You are not allowed to comment on this entry as it has restricted commenting permissions.

May 2006

Mo Tu We Th Fr Sa Su
Apr |  Today  | Jun
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31            

Search this blog

Tags

Galleries

Most recent comments

  • Interesting… While I'm not completely convinced in such microbenchmarks, I'm pretty sure that 1ms … by Alexander Snaps on this entry
  • Hello. I bought the book yesterday. I was trying to find the source code for chapter 11 and chapter … by Suleman on this entry
  • http://woosight.net/account/login?username=demo by live mashup demo on this entry
  • Thanks mate ….. This blog was really helpful. by Maaz Hurzuk on this entry
  • Ty. Not directly helpful for my problem, but pointed me in the right direction. You will also get th… by Mike E. on this entry

Blog archive

Loading…
Not signed in
Sign in

Powered by BlogBuilder
© MMXX