YOUR FEEDBACK
Three RIA Platforms Compared: Adobe Flex, Google Web Toolkit, and OpenLaszlo
NN wrote: Yeah you are right GWT is poor man's Flex. After using GWT on two...
SOA World Conference
Virtualization Conference
$200 Savings Expire May 16, 2008... – Register Today!

2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts

SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


Java Page Flow

Digg This!

Web application development is hard. Or rather, Web application development used to be hard.

Web application development used to be an activity that required developers to learn and use complex programming models. Web application development used to be an activity that required developers to manage the myriad details of configuring their Web application so that the various pieces of the application worked together. Web application development used to be an activity that was performed outside of the helpful environment of an IDE.

No longer.

The new Java Page Flow feature set of WebLogic Workshop version 2 makes Web application development easy. It provides a simple, easy-to-understand Web application programming model. Java Page Flow automatically manages Web application configuration details. And it provides a set of tools that help developers quickly and correctly build Web applications, and integrate those applications with business logic.

What Is It?
Java Page Flow is a feature set built on a Struts-based Web application programming model. It leverages the power and extensibility of Struts while eliminating the difficulties and challenges of building Struts-based applications. Java Page Flow features include runtime support for the Web application programming model and tools that enable developers to quickly and easily build applications based upon the model.

The central concept and construct of Java Page Flow is called page flow. Basically, a page flow is a directory of Web app files that work together to implement a UI feature. For example, a page flow could implement a Web app's user registration wizard feature. The files of this page flow could be arranged in a userRegistration directory as shown in Figure 1.

The userRegistration directory contains several *.jsp files, a *.jcx file and a *.jpf file. The *.jsp files are standard JavaServer Pages files that contain markup that describes the visual aspect of the user registration wizard. For example, name.jsp contains markup that describes a First Name and Last Name data entry form. The *.jcx file is a BEA innovation. It contains annotated Java code that implements logic used by the user registration wizard. UserManager.jcx contains code that implements a createUser( ) function.

The *.jpf file is also a BEA innovation and is the main focus of this article. It contains annotated Java code that implements the navigation and state management logic of the user registration wizard and makes calls to business logic. For example, UserRegistrationController.jpf contains code that decides that name.jsp should be presented before address.jsp, gathers the firstName and lastName information from name.jsp before presenting address.jsp, and calls the createUser( ) function of UserManager.jcx.

For those of you familiar with Struts and Model-View-Controller (MVC) programming, the files of the user registration wizard may be mapped to the 'M', the 'V', and the 'C' of MVC as seen in Table 1.

Page Flow Controllers
Page flow controllers are the main focus of this article. Let's take a step-by-step look at the contents of the UserRegistrationController.jpf file and how the file performs its navigation, state management, and logic-calling functions.

First, UserRegistrationController.jpf contains a class definition whose skeleton looks like this:

package userRegistration;

import com.bea.wlw.netui.pageflow.PageFlowController;

public class UserRegistrationController
extends PageFlowController
{
...
}

UserRegistrationController extends PageFlowController, which is a class that provides useful base class functionality and derives indirectly from org.apache.struts.action.Action. The base class functionality of PageFlowController provides support for things such as login and logout. The derivation from Action is an important aspect of the Struts interoperability of PageFlowController. Many classes in Java Page Flow inherit from Struts classes and interoperate with the Struts plumbing that serves as the foundation for the Java Page Flow runtime.

Actions and Navigation
Since UserRegistrationController acts as the controller for the user registration wizard, it contains code, in the form of action methods, that performs the page navigation decisions for the wizard. Action methods are methods invoked in response to things like form submissions. For example, UserRegistrationController contains an action method named name_next (see Listing 1).

The name_next action method is invoked whenever a user submits the form of the name.jsp page (see Listing 2).

The name_next action method decides that the address.jsp page should be the next page presented to a user. Because the name_next action method is invoked whenever a user submits the form of the name.jsp page, the name_next method effectively causes navigation from the name.jsp page to the address.jsp page.

All action methods have similar signatures. For example, they all have Forward as their return type. All action methods are specially annotated with @jpf:action to indicate to the *.jpf compiler that they should be configured as action methods in the auto-generated Struts configuration files. Also, action methods may be annotated with @jpf:forward to indicate to the *.jpf compiler and to the IDE tools the possible navigation decisions that the action methods may make such as deciding to forward to a page like address.jsp. Action methods are called by the page flow runtime and express their navigation decisions to the runtime by returning objects of type Forward to the runtime. The Forward objects encapsulate information described by the @jpf:forward annotations on the action methods.

The page flow runtime is responsible for selecting and calling action methods in controllers as part of the runtime's request processing life cycle. It is also responsible for executing the navigation decisions made by the action methods. In other words, if a user submits the form of address.jsp, the page flow runtime performs a request processing life cycle that includes these steps:
1.  Intercept the submission when it arrives at the application server.
2.  Determine that the name_next action method should be called.
3.  Call the name_next method.
4.  Receive the Forward("getAddress") object from the name_next method.
5.  Forward it to the address.jsp page described by the Forward("getAddress") object.

Page flow controllers may contain any number of action methods. For example, UserRegistrationController contains five action methods in addition to the name_next action method (see Listing 3).

Forms
In addition to selecting and calling action methods, the page flow runtime also passes to the action methods any form data that may have been submitted. For example, when a user submits the form of the name.jsp page, the page flow runtime captures the firstName and lastName data of the form in properties of a NameForm object, and passes the populated NameForm object to the name_next action method: package userRegistration (see Listing 4).

State Management
Java Page Flow provides a powerful, yet easy-to-use, foundation for state management that makes it simple for UserRegistrationController to perform its state management responsibilities. For example, to manage the form data that is received from pages such as name.jsp, code may be added to UserRegistrationController that captures the data in convenient instance members (see Listing 5).

Since the page flow runtime makes it possible to cache state in controller instance members, it's easy to implement support for a back button in a wizard. For example, if the confirmation.jsp page contained a back button, UserRegistrationController could respond to a press of the back button by navigating backward to the address.jsp page with all previously filled-out address.jsp form data still intact (see Listing 6; Listings 6-8 can be found online at www.sys-con.com/weblogic/source.cfm).

As you can see, the confirmation_back action method forwards backwards to the address.jsp page. As part of the forward, confirmation_back passes to address.jsp the address data that had already been received from address.jsp as an argument to the address_next action method.

Calling Business Logic
BEA WebLogic Workshop makes it easy to expose business logic as controls, and the Java Page Flow feature makes it easy to call controls from action methods. Because the page flow runtime performs automatic instantiation and initialization of controls for all instance members that are annotated with @common:control, action methods in page flow controllers may call Workshop controls without having to include code that performs control instantiation and initialization. For example, the confirmation_next action method can simply and directly call the createUser( ) method of UserManager.jcx: package userRegistration (see Listing 7).

BEA WebLogic Workshop makes it easy to expose all kinds of business logic as controls, including business logic that is implemented as EJBs. In other words, WebLogic Workshop even makes it easy to build Web applications over EJBs.

Additional Features
Java Page Flow contains many features in addition to those described above. For example, you may have noticed that the @jpf:forward annotation for the confirmation_next action method was a bit different from the other @jpf:forward annotations (see Listing 8).

The returnAction= "userRegistrationDone" attribute enables UserRegistrationController to participate in a Java Page Flow feature called "nesting."

Tools
As I mentioned earlier, the Java Page Flow feature set includes some IDE tools that help developers build Web applications. One example of such a tool is the new flow view that enables developers to architect entire Web applications using little more than simple drag -and- drop gestures (see Figure 2).

Like nesting, data binding, and custom tags, we'll take a look at the IDE tools in a future WLDJ article.

Take It for a Test Spin
For now, the best thing you can do is tdownload BEA WebLogic Workshop v2 and experiment with the new Java Page Flow features. See for yourself just how much easier Web application development can be.

Reproduced with permission from BEA Systems.

BEA WEBLOGIC LATEST STORIES
Microsoft To Keynote 4th International Virtualization Conference & Expo
Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs the tec
3rd International Virtualization Conference & Expo: Themes & Topics
From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in midtown
Virtualization Meets DaaS - Desktop-as-a-Service
After a $1.5 million angel round, Desktone, which was started in 2006 by Eric Pulier, who also started SOA Software, US Interactive and IVT, picked up $17 million in first-round funding about a year ago from Highland Capital Partners, SoftBank Capital, Citrix Systems and the China-base
Engelbart's Usability Dilemma: Efficiency vs Ease-of-Use
The mouse was the original idea of Doug Engelbart who was the head of the Augmentation Research Center (ARC) at Stanford Research Institute. Engelbart's philosophy is best embodied, in my opinion, in the design of another device that he invented, the five-finger keyboard - with keys li
Web 2.0 Is Fundamentally About Empowering People
'Unlocking content to be remixed into new business value' is the driver of Web 2.0 in the enterprise, says Rod Smith, IBM VP of Emerging Internet Technologies, in this Exclusive Q&A with Jeremy Geelan on the occasion of IBM's release of a new technology created by IBM researchers, code
Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
Here is a question that I have been pondering on and off for quite a while: Why do 'cool kids' choose Ruby or PHP to build websites instead of Java? I have to admit that I do not have an answer. Why do I even care? Because I am a Java developer. Like many Java developers, I get along w
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

MOST READ THIS WEEK
Chris Keene's Prescription for Curing the Java Flu
ADS BY GOOGLE
BREAKING NEWS FROM THE WIRES
AmberPoint Extends SOA Governance to Apache ServiceMix, BEA AquaLogic Service Bus 3.0, BEA WebLogic Integration, Cisco ACE XML Gateway, JBoss Enterprise Application Platform and Oracle Fusion
AmberPoint announced today that it has extended the reach of its runtime SOA governance