Announcement Announcement Module
Collapse
No announcement yet.
New PR3 Features under consideration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • New PR3 Features under consideration

    - States may now be parameterized with properties when they are entered by a calling Transition. Likewise the states themselves may have ${placeholders} that will be resolved to values at runtime, allowing you to reuse a single state in a different context (kind of like a template).

    Note: this replaces the action transition precondition support discussed in the earlier "bindAndValidate" thread on this forum. While that approach worked, it just didn't feel right: it made the flow less explicit, and a precondition really shouldn't have side effects.

    - A DecisionState type has been introduced, allowing you to evaluate one or more expressions to decide "where to go next" in a reusable way.

    See the following before/after code from the "sellItem" sample for examples of both of these features:

    Before new features

    Code:
    ?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE webflow PUBLIC "-//SPRING//DTD WEBFLOW//EN"
    	"http&#58;//www.springframework.org/dtd/spring-webflow.dtd">
    
    <webflow id="sellItem" start-state="setupForm">
    
    	<action-state id="setupForm">
    		<action bean="sellItemAction"/>
    		<transition on="success" to="enterPriceAndItemCount"/>
    	</action-state>
    
    	<view-state id="enterPriceAndItemCount" view="priceAndItemCountForm">
    		<transition on="submit" to="bindAndValidatePriceAndItemCount"/>
    	</view-state>
    	
    	<action-state id="bindAndValidatePriceAndItemCount">
    		<action bean="sellItemAction" method="bindAndValidate">
    			<property name="validatorMethod" value="validatePriceAndItemCount"/>
    		</action>
    		<transition on="success" to="enterCategory"/>
    		<transition on="error" to="enterPriceAndItemCount"/>
    	</action-state>
    	
    	<view-state id="enterCategory" view="categoryForm">
    		<transition on="submit" to="bindAndValidateCategory"/>
    	</view-state>
    
    	<action-state id="bindAndValidateCategory">
    		<action bean="sellItemAction" method="bindAndValidate"/>
    		<transition on="$&#123;#result == 'success' and flowScope.sale.shipping&#125;" to="enterShippingDetails"/>
    		<transition on="$&#123;#result == 'success' and !flowScope.sale.shipping&#125;" to="showCostOverview"/>
    		<transition on="error" to="enterCategory"/>
    	</action-state>
    	
    	<view-state id="enterShippingDetails" view="shippingDetailsForm">
    		<transition on="submit" to="bindAndValidateShippingDetails"/>
    	</view-state>
    
    	<action-state id="bindAndValidateShippingDetails">
    		<action bean="sellItemAction" method="bindAndValidate"/>
    		<transition on="success" to="showCostOverview"/>
    		<transition on="error" to="enterShippingDetails"/>
    	</action-state>
    	
    	<end-state id="showCostOverview" view="costOverview"/>
    
    </webflow>
    After new features

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE webflow PUBLIC "-//SPRING//DTD WEBFLOW//EN"
    	"http&#58;//www.springframework.org/dtd/spring-webflow.dtd">
    
    <webflow id="sellItem" start-state="setupForm">
    
    	<action-state id="setupForm">
    		<action bean="sellItemAction"/>
    		<transition on="success" to="enterPriceAndItemCount"/>
    	</action-state>
    
    	<view-state id="enterPriceAndItemCount" view="priceAndItemCountForm">
    		<transition on="submit" to="bindAndValidate">
    			<property name="validatorMethod" value="validatePriceAndItemCount"/>
    			<property name="successState" value="enterCategory"/>
    			<property name="errorState" value="enterPriceAndItemCount"/>
    		</transition>
    	</view-state>
    
    	<view-state id="enterCategory" view="categoryForm">
    		<transition on="submit" to="bindAndValidate">
    			<property name="successState" value="shippingRequired"/>
    			<property name="errorState" value="enterCategory"/>
    		</transition>
    	</view-state>
    
    	<decision-state id="shippingRequired">
    		<if test="$&#123;flowScope.sale.shipping&#125;" then="enterShippingDetails" else="showCostOverview"/>
    	</decision-state>
    
    	<view-state id="enterShippingDetails" view="shippingDetailsForm">
    		<transition on="submit" to="bindAndValidate">
    			<property name="successState" value="showCostOverview"/>
    			<property name="errorState" value="enterShippingDetails"/>
    		</transition>
    	</view-state>
    
    	<end-state id="showCostOverview" view="costOverview"/>
    
    	<action-state id="bindAndValidate">
    		<action bean="sellItemAction" method="bindAndValidate">
    			<property name="validatorMethod" value="$&#123;validatorMethod&#125;"/>
    		</action>
    		<transition on="success" to="$&#123;successState&#125;"/>
    		<transition on="error" to="$&#123;errorState&#125;"/>
    	</action-state>
    	
    </webflow>
    Use of the parameterization is of course completely optional, so the "Before new features" version still works perfectly fine.

    Let us know what you think. We're also enhancing FlowExecutionListener to provide support for state pre and post conditions.

  • #2
    Ok - can you tell we're going back and forth on this stuff? :-)

    Update:

    - We're going to put transition precondiitons back, after all, with first-class support for adapting actions to preconditions (very helpful with bindAndValidate).
    - We're kicking out DecisionState in favor of a DecisionAction.
    - We're kicking out state parameters: it smells.

    I'll update this forum when we're done demonstrating the real new PR3 features :-)

    Comment


    • #3
      I like that a lot. Not defining a bindAndValidate state for every view is going to be nice. When is it expected to "ship"?

      Comment


      • #4
        It's in CVS now. PR3 ship.

        Comment

        Working...
        X