Running H/F 1 325
icons, and Struts tools drawer with Action Mapping, Form Bean, Java Bean, Web
Page, Web Application, and Struts Module icons.
Figure 8-68 Web diagram with the struts drawer open in the palette
Adding the Web components
Use the icons in the palette to add two actions, two Web pages, and a form bean
on the empty surface:
1. When you drop an action, you can change its name to the name shown in
Figure 8-69.
Figure 8-69 Web diagram with initial components
326 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
2. When you drop a JSP page, you should change its name to the name shown
not only in the figure, but prepend the module name as well. For example, use
/btt/bank/ui/struts/withdrawal/withdrawal.jsp instead of
withdrawal.jsp.
3. When you drop a form bean, you are prompted for a name and scope. Enter
withdrawalForm as name and select request as scope.
Components in gray are not yet implemented, meaning they are only available in
the Web diagram and not as an underlying file such as a Java class or JSP.
Designing the application flow
When the components are laid out, connect them to define the flow of the
application. Figure 8-70 on page 327 shows the layout with connections.
1. Create a connection from withdrawal.jsp to /withdraw action.
This should be done to indicate the action that will be invoked when the form
is submitted.
Select Connection from the palette, click withdrawal.jsp, and drag the
connection to the /withdraw action.
2. Create a local forward back to withdrawal.jsp.
This will be used to forward the user back to the log in page when business
exceptions occur in the log in action.
a. Select Connection, click the /withdraw action, and drag it back to
withdrawal.jsp.
b. Rename the forward to failure and press Enter.
3. Create a local forward to the result.jsp.
a. Select Connection, click the /withdraw action, and drag it to result.jsp.
Note: You should add /prepareWithdrawal action because you are using
Struts modules. If you do not have these prepare actions, and you go to the
JSP pages directly, the subsequent submit action /withdraw cannot be found
by the Struts framework. The root cause is that the Struts framework would
not have initialized the struts-btt-withdrawal.xml module. Thus, before going to
withdrawal.jsp by selecting the /prepareWithdrawal action, Struts framework
can initialize the withdrawal Struts module. Then, the submission from
withdrawal.jsp can correctly direct to the /withdraw action in the
struts-btt-withdrawal.xml module.
Running H/F 1 327
b. Rename the forward to success and press Enter.
You will see a dotted arrow line from the /withdraw action to the result.jsp
page, as shown in Figure 8-70.
4. Associate the /withdraw action with the withdrawalForm form bean.
a. To create a connection, select the Connection icon from the Palette.
b. Single click the /withdraw action, and drag and drop the connection into
the withdrawalForm.
You will see a dotted arrow line from /withdraw action to the
withdrawalForm form bean as shown in Figure 8-70.
Figure 8-70 Web diagram with components connected
5. Save the Web diagram by pressing Ctrl+S.
Implementing the Struts Web diagram
Branch Transformation Toolkit Struts Extension includes BTTEJBActionMapping
and EJBAction Java classes that handle the connectivity between Struts Action
Mappings and Branch Transformation Toolkit Invokers. We use the built-in
EJBAction.
Thus, before actually starting, change the way the WebSphere Studio
Application Developer Integration Edition v5.1.1 realizes an action mapping,
when double-clicking the icon. Follow these instructions to make the change:
1. Select Window Preferences from the main menu bar.
2. Expand Web Tools Struts Tools, and then select Web Diagram Editor in
the left panel of the Preferences window.
328 IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines
3. Select the Invoke Struts Configuration File Editor option as the Preferred
action used when double-clicking an unrealized action mapping as shown in
Figure 8-71.
Figure 8-71 Use Struts Configuration File Editor to realize action mappings
After this change, you should consider the order of the component realization.
When the Web diagram is laid out, start implementing the components. This can
be done in different orders, and the support you get from the Struts tools
depends on the order you choose:
򐂰 You can implement the form beans first. When you later implement the JSPs,
you can choose which fields from the form beans that should be present on
the pages.

Get IBM Branch Transformation Toolkit 5.1 Migration and Usage Guidelines now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.