Nested Page Flows

 <  Day Day Up  >  

Nested Page Flows enable developers to separate a Web application into functional areas. In a typical Web site you might have user registration, user login, and searching as different functional areas in addition to the site's main portion. Nested Page Flows enable you to split the work of developing the site among several developers and then bring their work together later. You can create a separate Page Flow for each functional area and have a Page Flow that calls them. This way, you can have someone work on the user registration flow and another person work on the user login flow. You can then call these separate pieces in a Page Flow that's the basis for the whole site. This section shows how to add a nested Page Flow for the BuyChips application. This nested Page Flow is used to allow users to enter credit card information and charge the card before returning to the main Page Flow.

Creating a Nested Page Flow

Creating a nested Page Flow is not that different from creating a regular Page Flow or a JSP. Because this Page Flow will be part of the BuyChips application, you can simply right-click this folder and select the option to create a new Page Flow. The only additional step is selecting the Make This a Nested Page Flow check box, as shown in Figure 7.4.

Figure 7.4. Creating a nested Page Flow.

graphics/07fig04.gif

The only difference between using a Page Flow and a nested Page Flow is the presence of the exit state in nested Page Flows. Because you specified a nested Page Flow, when the flow is finished, control is relinquished to the calling flow. To signal that this flow has been completed, you link actions or pages to the done state, as shown in Figure 7.5. In Figure 7.5, note that the actual event name is CreditCardDone .

Figure 7.5. A nested Page Flow in Flow View.

graphics/07fig05.gif

Now that the nested Page Flow has been created, some other Page Flow needs to call it so that it's executed. To do this, drag the nested Page Flow's .jpf file onto the calling Page Flow. To call the nested Page Flow, you need an action. You can add one by using one of the following methods :

  • Edit an already existing action to call the flow.

  • Right-click the nested Page Flow icon in the Palette and select the Generate an Action icon. Then right-click the grayed-out exit condition in Flow View, and choose the Generate option to create an action for the exit condition.

The CreditCard Page Flow has been added to the BuyChips application in Figure 7.6.

Figure 7.6. A nested Page Flow added to a Page Flow.

graphics/07fig06.gif

Now what if someone gives you a Page Flow that he or she didn't think would be nested? How do you add it to your application? You take advantage of Workshop's Import feature by simply right-clicking on the application and choosing Import. Then navigate to the folder containing the Page Flow you would like to add and select it. Next , add any exit conditions needed for the Page Flow. Finally, just drag the .jpf file onto the calling Page Flow, as you have done before, to successfully add a Page Flow someone else has developed.

Nested Page Flow Architecture

Now that you've learned the mechanics of creating nested Page Flows, this section discusses how the server handles them.

In WebLogic Platform, when a nested Page Flow is executed, the calling Page Flow's information is placed on a stack associated with the user's session, and the nested Page Flow becomes the current one. A developer can access the parent's Page Flow variables from the nested Page Flow, but can't access a nested Page Flow's variable from the parent. Therefore, the best place to store attributes from the nested Page Flow is in the Request or Session object. Remember that Page Flow variables are lost after the flow has finished executing.

When the nested Page Flow is finished executing, its variables are destroyed and control is returned to the next Controller on the stack. The exit condition is returned from the nested Page Flow, and the parent Page Flow then determines where to go based on how it has been configured.

Figure 7.7 shows an example with two Page Flows: a parent Page Flow and a nested Page Flow. On the left is the Page Flow stack while the nested flow is being executed. The nested Page Flow will have access to both its variable z and the parent flow's variable x . When control is returned to the parent after the nested flow has been completed, the parent has access only to x .

Figure 7.7. Nested Page Flow architecture.

graphics/07fig07.gif

SHOP TALK : USING NESTED PAGE FLOWS TO IMPROVE ORGANIZATION AND PERFORMANCE

Nested Page Flows are a great way to divide work among different teams in a project. The key to using nested Page Flows is to separate the Web site into different functional areas. After defining the functional areas, you have each group develop its portion of the site. The Page Flows that were developed can then be brought together by using nested Page Flows.

Nested Page Flows can help improve your Web application's performance. By having a series of smaller flows, less memory needs to be allocated at a given time. Only the memory needed to run the parent flow and the current nested flow is in memory, and after the nested flow is finished executing, the memory is cleaned up.


 <  Day Day Up  >  


BEA WebLogic Workshop 8.1 Kick Start
BEA WebLogic Workshop 8.1 Kick Start: Simplifying Java Web Applications and J2EE
ISBN: 0672326221
EAN: 2147483647
Year: 2004
Pages: 138

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net