< 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 FlowCreating 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.
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.
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 :
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.
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 ArchitectureNow 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.
|
< Day Day Up > |