NetUI Page Flows: An Evolution of Strutsby Srinivas Jaini AbstractStruts is a popular framework used to build enterprise-level J2EE applications. With Struts, J2EE Web application development has become easier and more manageable. Beehive, an open-source project by the Apache Software Foundation, goes to great lengths to make Web application development even more straightforward by building a simple Page Flow model on top of Struts. Using the new JSR-175 and JSR-181 metadata annotation facilities, Beehive reduces the coding necessary for J2EE application development. This article introduces the Beehive Page Flow technology, and looks at how you can use it to increase the productivity and quality of Struts software. It also examines how you can migrate to include this technology in a vanilla Struts application. The article assumes you have some familiarity with Struts. Vanilla StrutsStruts, a part of the Jakarta project by the Apache Software Foundation, is an open-source framework for building Web applications based on the Model-View-Controller (MVC) design pattern. Struts uses action classes to build the controller component of a framework. A typical Struts application requires a number of action classes to handle several actions of a process flow and also an XML configuration file to declare forwards. Therefore, issues like data management and maintenance have become a major concern in existing Struts applications. Figure 1 shows a flow view of a sample application devised to make a comparative study between Struts and Page Flows.
This application, when developed in Struts, typically will
require action classes for each of the actions Listing 1. BeginAction.java
package comparision.struts;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public final class BeginAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
return (mapping.findForward("success"));
}
}
Similar action classes for Listing 2. struts-config.xml
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd" >
<struts-config>
<!-- Form Bean Definitions -->
<form-beans>
<form-bean name="UserForm" type="Samples.Struts.UserForm"/>
</form-beans>
<!-- Action Mapping Definitions -->
<action-mappings>
<action path="/Startup"
type="Samples.Struts.begin"
scope="request">
<forward name="login" path="/index.jsp"/>
</action>
<action path="/LoginForm" forward="/mypage.jsp"/>
<action path="/login"
type="Samples.Struts.Login"
name="LoginForm"
scope="request"
validate="false"
>
<forward
name="success"
path="/mypage.jsp"/>
</action>
</action-mappings>
<!-- message resources -->
<message-resources
parameter="ApplicationResources"
null="false" />
</struts-config>
|
Article Tools In This Series Related Technologies Related Articles Bookmark Article
|