Results 1 to 2 of 2

Thread: Using complex bean-action method results for transitions

  1. #1
    Join Date
    May 2007
    Posts
    11

    Question Using complex bean-action method results for transitions

    My question is similar to http://forum.springframework.org/showthread.php?t=38438 but with a twist...

    I need to pass back an object reference from a bean method in the case of success, so it can be added to the flow or conversation scope (not sure which yet).

    Specifically I am implementing an action state called 'doLogin', which invokes my service bean's doLogin(...) method with a form backing object set up by a previous state. This method needs to return three possible types of result - 'success', 'authMismatch', 'noSuchEntry' - and in the case of 'success' it needs to pass back the domain object (POJO) referring to the user's record.

    If I were just returning an Enum, I could do this:-

    <action-state id="doLogin">
    <bean-action bean="serviceBean" method="doLogin">
    <method-arguments>
    <argument expression="flowScope.login"/>
    </method-arguments>
    </bean-action>
    <transition on="success" to="loggedIn" />
    <transition on="authMismatch" to="start" />
    <transition on="noSuchEntry" to="start" />
    </action-state>

    But I need my domain object, which is where I'm stuck. I can return a composite object that combines the domain object with the enum, but the default result conversion rules (Table 2.11) mean I will always get "success" as my event identifier.

    Do I need to provide my own ResultEventFactory? How do I do that in the flow XML? Can this put the domain object into the appropriate scope?

    Or am I going about this all the wrong way?!?

    Rob

  2. #2
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    You can ofcourse also just code your own Action implementation and do all you need to do in Java. That's preferred in most non-trivial cases since it avoids to much "programming in XML". In that case you use a simple "<action>" instead of a "<bean-action>".

    Erwin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •