Announcement Announcement Module
Collapse
No announcement yet.
How to paramaterise action in the webflow.xml? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to paramaterise action in the webflow.xml?

    Hi all,

    A couple of questions. I have an action ActionA which locks a series of objects. I want to pass in a strategy which determines the objects to lock.

    There are a couple of implementations, used in different flows. I don't really want to have one bean in context.xml per strategy implementation, what I want is to effectively autowire in the flow.xml, i.e.:

    context.xml
    <bean id="lockAction"/> <!-- the action that locks the objects -->
    <bean id="individualObject"/> <!-- an implementation provide the objects -->
    <bean id="objectAndChildren"/> <!-- an implementation provide the objects -->

    and then in flow do something like:

    flow.xml
    <action name="lockAction">
    <property name="objectRetrievalStrategy">
    <ref bean="objectAndChildren"/>
    </property>
    </action>

    in another flow:
    <action name="lockAction">
    <property name="objectRetrievalStrategy">
    <ref bean="individualObject"/>
    </property>
    </action>

    If I cannot do this, then I suppose I could chain the two actions, and have the strategy populate the event or context that the lockAction then uses.

    If I chose this second approach, what would be the best approach in returning information from one event to another in the following scenarios:

    a: actionA is followed immediately by actionB
    b: actionA is followed by actionB which is followed by actionC, and actionC needs information produced by actionA.

    Should I populate the event, or the request context?

    Many thanks.

    Colin

  • #2
    Not very nice, but functional

    OK, so I have resorted to making the action implement ApplicationContextAware.

    At "flow" time the action is parameterised with the name of the bean it wants, i.e.:

    <action name="lockAction">
    <property name="individualObject"/>
    </action>

    During the action's execute method, I retrieve the bean from the application context.

    Bit nasty, but how else can I do it?

    Comment


    • #3
      Give the new type conversion machinery a try... it might actually work quite nicely.

      Specifically, create you a custom Converter -- like "TextToBean" and give it an alias when registered with the conversion service, like "bean" for example. Then in your xml say:

      <property name="objectAndStrategy" type="bean"/>

      ... that should pass the objectAndStrategy string to the converter for conversion, at which you could lookup the bean in the AC and return it. That way your action props end up being nicely typed strategies, not bean ids.

      Good luck.

      Keith

      Comment


      • #4
        Excellent. Will give it a try.

        Thanks.

        Comment


        • #5
          Haven't tried your ObjectType property editor yet, but could you not add another element into the "property" element called "ref" which does exactly this?

          Many thanks,

          Col

          Comment

          Working...
          X