Results 1 to 10 of 10

Thread: Multiple evaluate in <action-state> - transition not working

  1. #1
    Join Date
    Jun 2011
    Posts
    29

    Default Multiple evaluate in <action-state> - transition not working

    Hi All,

    I'm wondering why when I use multiple <evaluate expression> tags the transition does not pick up the result from the latest <evaluate>?
    The consumerResVO.getResult() value IS NO_CONSUMER_REQUEST_FOUND but the last transition is always executed.

    Code:
    <action-state id="checkConsumer">
    	<evaluate expression="consumerAction.authenticateRequest(flowRequestContext)" result="requestScope.consumerRes"/>
    	<evaluate expression="consumerRes.getResult()"/>
    	<transition on="NO_CONSUMER_REQUEST_FOUND" to="checkLocaleDomain">
    		<evaluate expression="consumerBean.setConsumerRequestFlag(false)" />
    	</transition>
    	<transition on="BACK_BUTTON_CLICKED" to="gotoConsumerBackButton"/>
    	
    	<!-- This ALWAYS executes -->
    	<transition to="checkConsumerRequest"/>
    </action-state>
    If I change this around to the following it works fine... but I'd rather not have to have multiple action states if not needed.

    Code:
    	
    <action-state id="checkConsumer">
    		<evaluate expression="consumerAction.authenticateRequest(flowRequestContext, flowScope.domainContext)" result="requestScope.consumerRes"/>
    		<transition to="checkConsumerResult"/>
    	</action-state>
    	
    	<action-state id="checkConsumerResult">
    		<evaluate expression="consumerRes.getResult()" />
    		<transition on="NO_CONSUMER_REQUEST_FOUND" to="notConsumerRequest"/>
    		<transition on="BACK_BUTTON_CLICKED" to="gotoConsumerBackButton"/>
    		<transition to="checkConsumerRequest"/>
    	</action-state>

  2. #2

    Default

    Off the top of my head, try using 'set' rather than 'evaluate' for the first action.

  3. #3
    Join Date
    Jun 2011
    Posts
    29

    Default

    Quote Originally Posted by Paul Wilson View Post
    Off the top of my head, try using 'set' rather than 'evaluate' for the first action.
    Tried this, did not make a difference unfortunately.

  4. #4
    Join Date
    Jun 2011
    Posts
    29

    Default

    I found that if I put the first evaluate into an <on-entry> it works... I'd still love to have an explanation as to why I need to do this? Just does not seem right.

  5. #5

    Default

    Quote Originally Posted by avalanche333 View Post
    I found that if I put the first evaluate into an <on-entry> it works... I'd still love to have an explanation as to why I need to do this? Just does not seem right.
    Webflow executes the actions in order until one of them produces a result that matches a transition. Since you have a wildcard transition:

    Code:
    <transition to="checkConsumerRequest"/>
    which is shorthand for
    Code:
    <transition on="*" to="checkConsumerRequest"/>
    this one is matched immediately from the first evaluate and therefore executed.

  6. #6
    Join Date
    Jun 2011
    Posts
    29

    Default

    Thanks a lot for clearing this up. I really appreciate it!

  7. #7
    Join Date
    Jun 2011
    Posts
    29

    Default

    Does set trigger transitions also?
    When I change the xml to use a set it still uses

    Code:
    <transition to="checkConsumerRequest"/>
    Code:
    <action-state id="checkConsumer">
    	<set name="requestScope.consumerRes" expression="consumerAction.authenticateRequest(flowRequestContext)" />
    	<evaluate expression="consumerRes.getResult()"/>
    	<transition on="NO_CONSUMER_REQUEST_FOUND" to="checkLocaleDomain">
    		<evaluate expression="consumerBean.setConsumerRequestFlag(false)" />
    	</transition>
    	<transition on="BACK_BUTTON_CLICKED" to="gotoConsumerBackButton"/>
    	
    	<!-- This ALWAYS executes -->
    	<transition to="checkConsumerRequest"/>
    </action-state>

  8. #8

    Default

    Quote Originally Posted by avalanche333 View Post
    Does set trigger transitions also?
    Yes, it triggers an event with id 'success' and therefore matches your catch-all transition. You can add 'on-entry' within your action state and do what you want within that, safe in the knowledge that no transition will be triggered.

  9. #9
    Join Date
    Jun 2011
    Posts
    29

    Default

    Quote Originally Posted by Paul Wilson View Post
    Yes, it triggers an event with id 'success' and therefore matches your catch-all transition. You can add 'on-entry' within your action state and do what you want within that, safe in the knowledge that no transition will be triggered.
    Ok thanks again!
    Is it proper practice to put "setup" type <sets> and <evaluate> in the <on-entry>?

  10. #10

    Default

    Quote Originally Posted by avalanche333 View Post
    Ok thanks again!
    Is it proper practice to put "setup" type <sets> and <evaluate> in the <on-entry>?
    An action-state, like a view-state, is looking for an 'event' to trigger a transition that it recognises. I was surprised to learn that 'set' causes an event and after consulting the code, can see that it does. 'on-entry' does not monitor actions for events, and is therefore the perfect solution in my humble opinion!

Tags for this Thread

Posting Permissions

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