Besides ease-of-use and other benefits that Page Flows offer, here are some important advantages of Page Flows:
Although this article is only an introduction to the basics, I hope you're getting a feel for how these features can contribute to creating large, manageable applications. The modularity and nesting features are particularly useful in composing reusable Web application components, while features such as session data management and rich data-binding tags contribute to ease of programming.
I hope the previous section has convinced you that Page Flows are a useful extension to Struts. Let's now look at ways in which you can add Page Flow functionality to existing Struts projects, or have Struts and Page Flow applications interoperate.
Page Flows are built on top of Apache Struts 1.1. Each Page Flow is compiled into a Struts module. As a result, Page Flow and Struts 1.1 applications can work closely together.
There are two approaches to using Struts components in Page Flow applications:
The Struts interoperability feature uses existing Struts-based components without modifying them. This allows existing Struts components to interact with Page Flow components and leverage existing JSP pages, action classes, forms beans, and flow configurations.
Struts and Page Flow applications can live and interact with each other inside a Web application. To forward from a Page Flow to a (pure) Struts module, simply reference the desired action within the Struts module. The same goes for the reverse direction: From a Struts module, simply configure an action to point to the desired method in the Page Flow.
A Page Flow can act as the front controller that processes the initial request and then passes the control over to actions within Struts that then do some processing and transfer control back to Page Flow. A similar pattern can be observed in nested Page Flows. Form beans can also be shared among Struts applications and Page Flows in these ways:
The files that comprise Struts modules and the Page Flows, if they are to interoperate, must exist in the same Web project.
Here are the requirements of Struts modules and Page Flows that will interoperate with each other in the same Web project:
<form-bean name=...>attribute must match exactly the value of the name attribute generated in the Page Flow's
This example shows how Page Flow actions can call Struts actions and vice versa. The purpose of this example is simply to show interoperability, and so the code is not complete. PageFlowActionA passes control, along with session-scoped form bean, over to StrutsActionA. StrutsActionA does some processing and forwards to
Page.jsp which has a Struts action, StrutsActionB. StrutsActionB passes control back to PageFlowActionB.