Seam is an interesting web framework that integrates the different pieces of the application stack and incorporates ideas from rules engines, BPM engines and SOA into regular application development. In this article, the focus is on Seam’s navigation and flow related features. Let’s see how they could play out in practice.
The article logically divides the topic into two parts, which map to the two navigation models, namely stateless and stateful. In Seam, stateless implementation uses JSF style pageflows while the stateful implementation uses jPDL pageflows.
Navigation from page to page, or view to view, in a web application can either be agnostic to or be governed by the state of the application. In other words, it could be stateless or stateful. In a stateless model a set of rules map action or event outcomes to specific views or pages. On the contrary, in a stateful model the navigation rules define transitions from one state to the other, which in the process causes transition from one view or page to the other. You may ask why navigation models need to be stateful at all and you may also ask how the state information could be tied in with the navigation rules. Both the questions are pertinent and important so I will try and answer them right away.
In a process driven web application the flow from one page to the other is often governed by the application state and the decision tasks which use this state information. As an example, consider a loan processing application manifesting as a web application. In this application a user could be transitioned from the “welcome page” to the “loan information capture page” or “modify and confirm information page”. The choice of the page to transition to will depend on the applicant being an existing approved customer or not. An existing customer would be sent to the “modify and confirm information page” since most information pertinent to the loan processing is already available, while a new customer would be directed to the “loan information capture page” as basic information needs to be available before any further decisions can be made. Assume that such an application also gives the user a choice to upgrade its approval status. As an example the particular user may be approved for loan upto $500,000 but now needs to upgrade the loan approval amount to $1 million. In this example at the “modify and confirm information page” the user will choose to upgrade the loan amount and so would be diverted to “get additional information page”. You see what is happening here, the navigation is essentially mirroring the viable transitions which depend on the current state of the application. It’s a state transition scenario, that’s it! This flow is depicted in Figure titled: “The loan approval application process flow”.
Figure 1: The loan approval application process flow
The example clearly illustrates a need to define navigation as a set of rules that is constrained by the allowed transitions from the application state at every stage of the process. This is essentially what a stateful pageflow is all about and the example depicts a typical use case where it is applicable.
Next, let’s address the question of how one could implement stateful navigation rules. It is simple and there are many ways to do it. We need a mechanism to specify the process and a way to translate this process description into executable code. There are numerous process definition languages available today, that can successfully describe a process with simplicity. jPDL, BPEL and XPDL are examples of XML based process description languages. These define tags which describe tasks, states and decisions and allow processes to fork and join. Certainly, there are differences in terms of specific tag names and the complete vocabulary of these tags, among these process description languages. Workflow engines can execute the process defined in one or many of such languages. jPDL process descriptions can be successfully executed by jBPM, the JBoss workflow and business process management engine. Seam integrates with jPDL and utilizes jBPM to execute the described process. You do not need to be an expert in either jPDL or jBPM to use Seam and you can skip this entire facility if you don’t need stateful pageflows at all. However, Seam provides a clean and easy way to implement stateful pageflows and you will be benefited greatly by getting conversant with this option.