Level: Advanced Nicolas Dangeville (dangeville.n@fr.ibm.com), Solution Architect, IBM
05 Sep 2006 This article describes the Web Application Models Folder Wizard that supports IBM® Rational® Application Developer and is provided by the VisualAge® Pacbase eBusiness module. It explains the rules that it applies to generate a complete Web application for a VisualAge Pacbase eBusiness folder. Web Application Models and the related Folder Wizard are powerful tools that enable you to very quickly create a Web application from folders. You can take advantage of this ability for tests, prototypes, and initial development.
Advantages of using the VisualAge Pacbase eBusiness module to develop Web applications
The VisualAge Pacbase eBusiness module enables you to describe a folder that contains various nodes. Each node has a description of its data and operations, and the nodes are linked together by relationships, such as containment or reference with single or multiple cardinalities. They form a directory tree, starting at the root node. Starting with Version 3.5 V02, the VisualAge® Pacbase eBusiness module includes a wizard that uses the Web Application Models technology to process all of the nodes of the proxy at once. This is an easy-to-use tool that supports Rational Application Developer and enables you to describe and generate a set of Web pages (JSP™) and the associated controller logic (Apache Struts framework) for each node of the proxy.
The e-business module generates the VisualAge Pacbase servers, which are elementary servers driven by the folder manager server. These servers handle the logic and data access, as well as the Java™ proxy that enables a Java client to communicate with the servers.
The Java proxy is a set of Java classes that perform functions to help with client/server programming. For example, a proxy contains a cache that can store changes made to various nodes and commit them simultaneously. The Java proxy removes the 32 Kb message size limitation by automatically sending as many messages as necessary without any action by the developer.
Developers often use the VisualAge Pacbase eBusiness module and Java
proxies to create Web applications. You can use the Web Application Models
technology to do that faster and easier. This technology is a feature of
the VisualAge Pacbase eBusiness module, which runs in Rational Application
Developer.
 |
Patterns in Web Application Models
A pattern represents a default organization of the application fragment that you are building for a node of a folder. It describes the presentation (such as possible combination of selection criteria form, list, detail forms in multiple pages), navigation, application logic (which operations to perform against the data) and data access. Web Application Models provide more than 80 patterns.
|
|
With Web Application Models, you need to create as many iterations as there are nodes in the folder to take into account all of the nodes of a VisualAge Pacbase eBusiness folder. Even if most of the code is generated, using a new iteration on each node is not an error-free process, and there are several things that you must remember to do (see Figure 1):
- Choose consistent patterns to apply to each node. You must select compatible patterns, depending on the relationship between two nodes.
- Generate each fragment in the appropriate place (in the same Web project). You need to make sure that one generation will not override what another generation has created, bearing in mind that the default names may be similar.
- Connect the generated pages to assemble the various fragments that you have generated. You need to find the pages to process, and then create a correct connection in the form of a link in the JSP that targets the appropriate page or action.
Figure 1. The Web Application Models process
This solution does not take advantage of all the information that the proxy
includes, such as the relationships between the nodes of the folder. The
Web Application Models Folder Wizard takes advantage of that information.
The Web Application Models Folder Wizard
Let's take a closer look at the Folder Wizard by using an example.
Figure 2 shows the contents of the Customer for Sharehold folder as it is displayed by the Service Test Facility provided by the VisualAge Pacbase eBusiness tools. It deals with customer and trade management.
Figure 2. A proxy in the Service Test Facility
This folder contains a root node called Customer, which owns one or several accounts and has one or several addresses. It also contains a list of transactions and a list of portfolios. A portfolio is a reference to a company, although a transaction also references a company.
Let's focus on a a couple of interesting points in this example:
- The company is referenced twice, from Customer Transaction and Customer Portfolio.
- The customer owns several lists of objects. Some of these multiple relationships have a {0..n} cardinality (transaction, portfolio), but some of them have a {1..n} cardinality (account, address).
- Because of the {1..n} relationship, a customer is required to have at least one account and one address.
The Web Application Models Folder Wizard can process this folder and generate the Web application that corresponds to the nodes it contains. You can launch this wizard from either the toolbar or the File > New ... Web category.
This wizard is actually very simple and consists of only two pages. In the first page of the wizard (Figure 3), you select the proxy that you want to process.
Figure 3. The Folder Wizard: Step 1
The second page of the wizard (Figure 4) is the same page that you see at the end of the Web Application Models wizard.
Figure 4. The Folder Wizard: Step 2
Artifacts generated by the Web Application Models Folder Wizard
Given that it's the same page, you may wonder: What exactly did the wizard generate? Rather than examine the generated artifacts themselves, the simplified diagram in Figure 5 gives a good overview of the Web pages and the functions of the application.
Figure 5. The generated Web pages
The application starts with the selection criteria you used to build a list of customers. From the list, you can either open the detail of a customer record or create a customer record, which makes it a regular list-and-detail situation.
Look closer at the creation of a customer entry, though. You saw that creating a customer record involves providing the fields for the customer (name and so forth). But it also involves creating an account and an address. This is what the pages linked to Create Cust are about. Therefore, you can open the pages to create a customer account and a customer address from the page dedicated to creating a customer record.
The detail page of a customer record provides links to all of its related objects. Because there are multiple relationships between the parent customer record and all of its child nodes, all of the pages for the customer-related objects start with a list. From each list, you again have a regular list-and-detail situation: a page where you can see the detail of a row of the list, plus a page where you can create a new element. (In the diagram, the links from Cust Address to Create Address and to CustAccount, where you create an account, are not displayed.)
So far, you have seen pages that deal with child nodes owned by parent nodes. Now you'll see what happens with reference relationships. In the sample folder, Company is referenced from both Customer Transaction and Customer Portfolio. Therefore, as Figure 6 shows, a Company detail page is available from both the Customer Portfolio detail page and the Customer Transaction detail page. The diagram displays the current company referenced by those nodes. A list of companies is also available from the Transaction and Portfolio creation pages, which helps you find the company code used in the creation detail.
Wizard generation rules
In this example, you see that several things have happened that differ from a regular Web Application Models generation. For each node, a given pattern has been selected and additional navigation links have been generated according to the directory tree formed by the nodes of the folder. The folder contains information about the nature of the relationship between two nodes (composition, reference) and about the cardinality of this relationship (zero to one, one to one, zero to many, one to many).
The wizard selects an appropriate pattern for each node, starting from the root node and following the relationships on each node to other nodes. Each pattern is applied to one node of the proxy. This is not enough to build the application, because the fragments generated from each pattern are still disconnected. The wizard also adds the navigation actions to the page to provide the appropriate navigation for related nodes.
This default application is similar to what you would have generated with the regular Web Application Models through n iterations (one per node, selecting the appropriate patterns), followed by modifying the generated code to assemble the pages manually. In essence, this process takes maximum advantage of the information from the folder nodes in VisualAge Pacbase to deduce the characteristics of the pages and the navigation paths to generate, which saves you considerable time and trouble.
Figure 6. Web Application Models Folder Wizard process
The Web Application Models Folder Wizard processes a folder according to these rules (also see Figure 6) :
- For the root node, the wizard applies the following pattern:
- 1st page: List.
- 2nd page: Zoom from an item of the list into a detail. Navigation actions are added to reach the first page of the pages generated for its dependent or referenced nodes.
- 3rd page: Detail for creation (you can open it from a link on the list page).
- For a dependent node that is related to its parent with a multiple {0..n} cardinality, it applies this pattern:
- 1st page: List.
- 2nd page: Zoom from an item of the list into a detail. Navigation actions are added to reach the first page of the pages generated for its dependent or referenced nodes.
- 3rd page: Detail for creation (you can open it from a link on the list page). For required child nodes ({1..1}, {1..n}) or dependent nodes, a navigation action is added that targets the creation page of the child node.
- For a dependent node that is related to its parent with a single {0..1} cardinality,
the wizard uses the following pattern:
- 1st page: Detail with either Update or Create action, depending on the possible actions provided by the node.
- For required child nodes ({1..1}, {1..n}) or dependent nodes, a navigation action is added that targets the creation page of the child node.
- For a referenced node (regardless of the cardinality), the following pattern is applied:
- 1st page: List (reachable from the parent node, so you can see the list of all the instances of the referenced node).
- 2nd page: Zoom from an item of the list into a detail. A link is added from the detail page of the parent to the detail page of the node.
Benefits of using the wizard
With this wizard, you can quite quickly create a default Web application that takes an entire folder into account. This makes it very easy to test the generated Java proxy. You can also use the code generated by the wizard as a way to learn and to understand the API of the proxy's Java classes. The proxy makes it very simple to navigate through the nodes, update information at various places in the hierarchy, and then commit all of the changes at once.
You can also use what the wizard produces as the starting point to implement a full application: the wizard generates the models, too, not just the code. When you use Web Application Models to create an application, you can later modify that application with Web Application Models because it stores the model of the application. This works for applications generated by the Folder Wizard, too.
Here's how you can use Web Application Models to refine what the Folder Wizard produces:
When you start Web Application Models, rather than using the default option in the first page of the wizard, use the second one (see Figure 7).
Figure 7. Modify the model for a node
A dialog screen (Figure 8) helps you select the model file that has been saved with your application.
Figure 8. Select the model file
The wizard recognizes the pattern used and the associated data (see Figure 9).
Figure 9. View the pattern used
From this wizard, you can tune the parameters of the Web Application Models and create, for each node of the proxy, pages that are closer to what you want to develop. For example, you can modify the layout of the pages, as Figure 10 shows.
Figure 10. Change the pages
Note: The links that are related to the navigation between the nodes are still present in the wizard.
Summary
The Folder Wizard is an addition to the Web Application Models technology that allows you to take maximum advantage of the contents of a VisualAge Pacbase eBusiness folder, including its hierarchy of nodes. The combination of the Folder Wizard and the Web Application Models wizard, both supporting Rational Application Developer, gives you a quick solution to test a proxy and to start the development of a Web application.
Acknowledgments
Thanks to Hervé Le Bars for his technical review of this article.
Resources Learn
Get products and technologies
Discuss
About the author  | |  | Nicolas Dangeville is a Solution Architect at the IBM laboratory in Paris. He was the lead architect of the Web Application Models technology and is now on the Enterprise Software Architecture Board and involved in the VisualAge Pacbase transition to the Sofware Development Platform. |
Rate this page
|