Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Spring WebFlow Sneak Preview: Reuse and Framework Abstraction : Page 3

Spring WebFlow is a new Web framework that brings an innovative and highly structured approach to building Web applications. Get a sneak peek of the features in this next-generation Spring offering.


advertisement

Reuse with WebFlow

The flow definitions in WebFlow, like LoginSequence, are intentionally structured for reuse. They have well defined entry and exist states, and the states and transitions have well encapsulated lifecycles. The definitions are easy to configure and reuse with the Spring-enabled Web components. Architects should recognize and define common flows, such as login sequences, searches, and summary-details displays, and have them defined as reusable flows.

Furthermore, Actions, if architected properly in conjunction with the Spring framework, also are reusable components. They can be made parts of the action states in the multiple flows as well. This reuse, at both the overall Web-application and the flow levels in the action states, helps reduce the overall size of your application and improves its maintainability and understandability.

WebFlow Integration with Struts

WebFlow integrates with Struts out of the box, partly through the standard Spring classes and configurations available in the org.springframework.web.struts package. Integration with WebFlow-specific concepts, such as Actions and ActionFlows, requires only registering the Actions to be executed with WebFlow-specific Struts actions and incorporating them into an ActionFlow.



The following snippet is from struts-config.xml. It illustrates how the Struts Action is configured as an entry point to the flow. Notice the WebFlow-specific type for the Action class (org.springframework.web.flow.struts.FlowAction), and the property "flowId", which connects the Action to the login sequence flow. The example login sequence is managed as a loginFlow bean in the Spring's ApplicationContext. You would need to register the flow as a Spring-managed bean:

<!— flow actions —> <action path="/loginFlow" type="org.springframework.web.flow.struts.FlowAction" name="actionForm" scope="request" className="org.springframework.web.flow.struts.FlowActionMapping"> <set-property property="flowId" value="loginAction" /> </action>

The example also uses the RequestProcessor from the Spring framework, (org.springframework.web.struts.BindingRequestProcessor) which enables Spring's automatic form-to-bean object binding. This Spring feature prevents a proliferation of individual transient ActionForm objects:

<controller processorClass="org.springframework.web.struts.BindingRequestProcessor"/>

As well, it requires the use of the convenience class, which auto-binds Web form values to Java objects' properties:

<plug-in className="org.springframework.web.struts.BindingPlugin"/>

The WebFlow pre-release, which is available for immediate download, contains a short and effective sample application ("birthdate") that illustrates all the major points in this integration process. If you are interested in WebFlow, explore this sample application.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap