Announcement Announcement Module
Collapse
No announcement yet.
Multiple evaluate in <action-state> - transition not working Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Off the top of my head, try using 'set' rather than 'evaluate' for the first action.

    Comment


    • #3
      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.

      Comment


      • #4
        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.

        Comment


        • #5
          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.

          Comment


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

            Comment


            • #7
              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>

              Comment


              • #8
                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.

                Comment


                • #9
                  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>?

                  Comment


                  • #10
                    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!

                    Comment

                    Working...
                    X