Announcement Announcement Module
No announcement yet.
Using complex bean-action method results for transitions Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using complex bean-action method results for transitions

    My question is similar to 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">
    <argument expression="flowScope.login"/>
    <transition on="success" to="loggedIn" />
    <transition on="authMismatch" to="start" />
    <transition on="noSuchEntry" to="start" />

    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?!?


  • #2
    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>".