Announcement Announcement Module
Collapse
No announcement yet.
input/output mapper in 1.0RC2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • input/output mapper in 1.0RC2

    Another problem just surfaced:
    my input/output mapper doesn't work with subflow. Here is my syntax under a subflow-state:
    <attribute-mapper>
    <input-mapper><mapping source="${flowScope.newForm}" target="newForm" /></input-mapper>
    <output-mapper><mapping source="newForm" target="flowScope.newForm" /></output-mapper>
    </attribute-mapper>

    I assume this will do the following:
    1. take the newForm object (which is the backing form for the underlying FormAction) and place it under the Flow Scope of the subflow, with the bean name "newForm";

    2. When the subflow ends, do a reverse mapping, take the subflow "newForm" and place it in the current flow's flowScope

    However, it seems that the newForm is never passed to the subflow, and everytime I enter the subflow, a new instance of the form object is created. When the subflow ended, a NULL is passed back, and created an exception.
    Thank you for your help.

    -JJ

  • #2
    JJ,

    SWF doesn't go quite as far as your #1 assumption--it will expose 'newForm' as an input attribute to your subflow, but it's still the responsibility of that flow to map that input attribute as it sees fit (otherwise it will be effectively ignored). This mapping process forms the input contract for the flow, so it's very clear what a flow requires as input.

    Keith

    Comment


    • #3
      The following may help: http://blogs.warwick.ac.uk/colinyate..._web_flow_1_2/

      Comment


      • #4
        Thanks for your help.
        I placed the <input-mapper>...</input-mapper> in my subflow, and it starts working if this subflow is accessed from parent flow.

        However, in certain situations, the subflow will be accessed directly as a stand-alone flow (in this case, the newForm will be created automatically as the backing form for the FormAction). I got an exception because the input attribute for "newForm" is null. Anyway to avoid this? The older version of SWF I used before (with a different mapper syntax, and seems no input-mapper is required to be specified in subflow) was working fine in either scenarios.

        Thanks again.

        -JJ

        Comment


        • #5
          Hmm...if newForm is null it should just be a no op, arguably.

          Could you post the input mapper snippet and the problem you're seeing?

          Keith

          Comment


          • #6
            Keith, thanks for the quick response.

            Here are relevant parts of my flow definition and code:

            1. parent flow:

            ......
            <subflow-state id="deleteSelection" flow="delete-flow" >
            <attribute-mapper>
            <input-mapper>
            <mapping source="${flowScope.newForm}" target="newForm" />
            </input-mapper>

            <output-mapper>
            <mapping source="newForm" target="flowScope.newForm" />
            </output-mapper>
            </attribute-mapper>
            <transition on="finish" to="setupForm" />
            <transition on="error" to="compListDeleteForm" />
            </subflow-state>
            ......

            2. subflow:
            <flow start-state="deleteSelection">
            <input-mapper>
            <mapping source="newForm" target="flowScope.newForm" />
            </input-mapper>

            <action-state id="deleteSelection" >
            <action bean="deleteFlowAction" method="deleteSelection" />
            <transition on="*" to="requireForward" />
            </action-state>
            .....
            <end-state id="finish">
            <output-mapper>
            <mapping source="${flowScope.newForm}" target="newForm" />
            </output-mapper>
            </end-state>

            3. Code snippet of the FormBean (DeleteFlowAction)
            public Event deleteSelection(RequestContext ctx) throws Exception
            {
            Event e = bindAndValidate(ctx); //---------- HERE IS WHERE THE EXCEPTION OCCURS
            if (e.getId().equals("error")) {
            return e;
            }
            ..........


            4. The exception happens when the bindAndValidate(ctx) call is made when subflow is entered as a stand-alone flow. It seems that the InputMapper is setting the "newForm" to null. By the way, I am using the same FormAction controller for the parent flow and the subflow. Does this mean that in my deleteSelection() method, I need to check if the "newForm" is null or not, then create it if it is null, and then call bindAndValidate()?

            java.lang.IllegalArgumentException: Map key 'newForm' has value [null] that is not of expected type [class com.genentech.bioinformatics.mslims.flow.model.Del eteForm],
            instead it is of type [null]
            at org.springframework.binding.util.MapAccessor.asser tKeyValueInstanceOf(MapAccessor.java:455)
            at org.springframework.binding.util.MapAccessor.asser tKeyValueOfType(MapAccessor.java:442)
            at org.springframework.binding.util.MapAccessor.get(M apAccessor.java:95)
            at org.springframework.binding.util.MapAccessor.get(M apAccessor.java:78)
            at org.springframework.webflow.AbstractAttributeMap.g et(AbstractAttributeMap.java:113)
            at org.springframework.webflow.action.FormObjectAcces sor.getFormObject(FormObjectAccessor.java:115)
            at org.springframework.webflow.action.FormAction.getF ormObject(FormAction.java:632)
            at org.springframework.webflow.action.FormAction.bind AndValidate(FormAction.java:454)
            at com.genentech.bioinformatics.mslims.flow.controlle r.DeleteFlowAction.deleteSelection(DeleteFlowActio n.java:62)

            Comment


            • #7
              Hmmm.... it is interesting the "newForm" key is actually present with a "null" value. It's arguable the key shouldn't be present at all if its value is null--and if it wasnt your FormAction would've created a new one automatically. This would mean a bug in the input mapper. We need to look at this.

              In any case, a workaround would yes to be to manually create the newForm bean if it doesn't exist already.

              Keith

              Comment


              • #8
                I have actually run into the same issue...

                I have a flow that edits an object. That edit flow is used both stand-alone, and as a sub-flow.

                In order for the edit flow to be used as a sub-flow, I MUST declare an input-mapper.
                If I use it stand alone I get an illegal argument exception because the mapped attribute is null.

                Code:
                java.lang.IllegalArgumentException: Map key 'propertyDefinition' has value [null] that is not of expected type [class com.company.product.MyFormBean], instead it is of type [null]
                	at org.springframework.binding.util.MapAccessor.assertKeyValueInstanceOf(MapAccessor.java:455)
                	at org.springframework.binding.util.MapAccessor.assertKeyValueOfType(MapAccessor.java:442)
                	at org.springframework.binding.util.MapAccessor.get(MapAccessor.java:95)
                	at org.springframework.binding.util.MapAccessor.get(MapAccessor.java:78)
                	at org.springframework.webflow.AbstractAttributeMap.get(AbstractAttributeMap.java:113)
                	at org.springframework.webflow.action.FormObjectAccessor.getFormObject(FormObjectAccessor.java:148)
                	at org.springframework.webflow.action.FormAction.getFormObject(FormAction.java:700)
                	at org.springframework.webflow.action.FormAction.setupForm(FormAction.java:481)
                ...
                So basically the new input/output mapping requirements are causing a catch 22 here.

                I am using Webflow 1.0-RC3

                Comment


                • #9
                  Yes, can you create a JIRA Ray.

                  Comment


                  • #10
                    Done
                    http://opensource.atlassian.com/proj...browse/SWF-149

                    Comment

                    Working...
                    X