Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Java Page Flow

Java Page Flow

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).

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."

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.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

@ThingsExpo Stories
To Really Work for Enterprises, MultiCloud Adoption Requires Far Better and Inclusive Cloud Monitoring and Cost Management … But How? Overwhelmingly, even as enterprises have adopted cloud computing and are expanding to multi-cloud computing, IT leaders remain concerned about how to monitor, manage and control costs across hybrid and multi-cloud deployments. It’s clear that traditional IT monitoring and management approaches, designed after all for on-premises data centers, are falling short in ...
Organizations planning enterprise data center consolidation and modernization projects are faced with a challenging, costly reality. Requirements to deploy modern, cloud-native applications simultaneously with traditional client/server applications are almost impossible to achieve with hardware-centric enterprise infrastructure. Compute and network infrastructure are fast moving down a software-defined path, but storage has been a laggard. Until now.
DXWorldEXPO LLC announced today that the upcoming DXWorldEXPO | CloudEXPO New York event will feature 10 companies from Poland to participate at the "Poland Digital Transformation Pavilion" on November 12-13, 2018.
Digital Transformation is much more than a buzzword. The radical shift to digital mechanisms for almost every process is evident across all industries and verticals. This is often especially true in financial services, where the legacy environment is many times unable to keep up with the rapidly shifting demands of the consumer. The constant pressure to provide complete, omnichannel delivery of customer-facing solutions to meet both regulatory and customer demands is putting enormous pressure on...
The best way to leverage your CloudEXPO | DXWorldEXPO presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering CloudEXPO | DXWorldEXPO will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at CloudEXPO. Product announcements during our show provide your company with the most reach through our targeted audienc...
In an era of historic innovation fueled by unprecedented access to data and technology, the low cost and risk of entering new markets has leveled the playing field for business. Today, any ambitious innovator can easily introduce a new application or product that can reinvent business models and transform the client experience. In their Day 2 Keynote at 19th Cloud Expo, Mercer Rowe, IBM Vice President of Strategic Alliances, and Raejeanne Skillern, Intel Vice President of Data Center Group and ...
More and more brands have jumped on the IoT bandwagon. We have an excess of wearables – activity trackers, smartwatches, smart glasses and sneakers, and more that track seemingly endless datapoints. However, most consumers have no idea what “IoT” means. Creating more wearables that track data shouldn't be the aim of brands; delivering meaningful, tangible relevance to their users should be. We're in a period in which the IoT pendulum is still swinging. Initially, it swung toward "smart for smart...
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world.
DXWorldEXPO LLC announced today that All in Mobile, a mobile app development company from Poland, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. All In Mobile is a mobile app development company from Poland. Since 2014, they maintain passion for developing mobile applications for enterprises and startups worldwide.
In his keynote at 19th Cloud Expo, Sheng Liang, co-founder and CEO of Rancher Labs, discussed the technological advances and new business opportunities created by the rapid adoption of containers. With the success of Amazon Web Services (AWS) and various open source technologies used to build private clouds, cloud computing has become an essential component of IT strategy. However, users continue to face challenges in implementing clouds, as older technologies evolve and newer ones like Docker c...
DXWorldEXPO LLC announced today that ICC-USA, a computer systems integrator and server manufacturing company focused on developing products and product appliances, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. DXWordEXPO New York 2018, colocated with CloudEXPO New York 2018 will be held November 11-13, 2018, in New York City. ICC is a computer systems integrator and server manufacturing company focused on developing products and product appliances to meet a wide range of ...
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
We are seeing a major migration of enterprises applications to the cloud. As cloud and business use of real time applications accelerate, legacy networks are no longer able to architecturally support cloud adoption and deliver the performance and security required by highly distributed enterprises. These outdated solutions have become more costly and complicated to implement, install, manage, and maintain.SD-WAN offers unlimited capabilities for accessing the benefits of the cloud and Internet. ...
Headquartered in Plainsboro, NJ, Synametrics Technologies has provided IT professionals and computer systems developers since 1997. Based on the success of their initial product offerings (WinSQL and DeltaCopy), the company continues to create and hone innovative products that help its customers get more from their computer applications, databases and infrastructure. To date, over one million users around the world have chosen Synametrics solutions to help power their accelerated business or per...
Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online community solutions firm, 7Summits.
Founded in 2000, Chetu Inc. is a global provider of customized software development solutions and IT staff augmentation services for software technology providers. By providing clients with unparalleled niche technology expertise and industry experience, Chetu has become the premiere long-term, back-end software development partner for start-ups, SMBs, and Fortune 500 companies. Chetu is headquartered in Plantation, Florida, with thirteen offices throughout the U.S. and abroad.
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
Charles Araujo is an industry analyst, internationally recognized authority on the Digital Enterprise and author of The Quantum Age of IT: Why Everything You Know About IT is About to Change. As Principal Analyst with Intellyx, he writes, speaks and advises organizations on how to navigate through this time of disruption. He is also the founder of The Institute for Digital Transformation and a sought after keynote speaker. He has been a regular contributor to both InformationWeek and CIO Insight...
"IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...