Results 1 to 4 of 4

Thread: New PR3 Features under consideration

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default 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.
    Keith Donald
    Core Spring Development Team

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    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 :-)
    Keith Donald
    Core Spring Development Team

  3. #3

    Default

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

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    It's in CVS now. PR3 ship.
    Keith Donald
    Core Spring Development Team

Similar Threads

  1. New PR3 Features
    By Keith Donald in forum Web Flow
    Replies: 5
    Last Post: Apr 27th, 2005, 02:25 AM
  2. Spring major Features
    By Rasheed in forum Web Flow
    Replies: 4
    Last Post: Apr 21st, 2005, 10:24 PM
  3. new features request?
    By volenin in forum Meta
    Replies: 1
    Last Post: Jan 25th, 2005, 05:22 PM
  4. Replies: 7
    Last Post: Oct 27th, 2004, 03:40 PM
  5. org.springframework.remoting.simple features?
    By vmarcinko in forum Remoting
    Replies: 1
    Last Post: Sep 17th, 2004, 03:02 AM

Posting Permissions

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