IBM WebSphere Host Access Transformation Server (HATS)

Tutorial Module 5

Customizing HATS applications - Business Logic and Global Variables

Abstract

This tutorial is designed for anyone who wants to learn how to customize HATS applications. The tutorial is in the form of a lab exercise to a live publicly available host application. This module will cover some of the possible customization steps and how to apply different actions based upon recognized screen events. This will demonstrate HATS global variables and business logic.

Assumptions / Requirements

It is assumed that the user has already installed WebSphere Studio 4.03 and the HATS Studio software on a supported platform. The platform requirements were covered in the HATS Tutorial - Module 1.

It is also assumed that a network connection can be made to the publicly accessible IBM Demonstration iSeries host at:

Host name: iseriesd.dfw.ibm.com, port: 23, type: 5250

Connectivity to this host can be tested by using any TN5250 emulator configured for the settings above. A WebSphere application server that meets the requirements for HATS needs to be available if you want to deploy the HATS application to a production WebSphere server. It is assumed that you are already familiar with the WebSphere application server console.

Topics covered on this tutorial

Review Basic HATS application steps

You can reuse the previously configured HATS application from Module 4 for this tutorial. If you have a previously configured HATS application that you want to use from Module 2, then skip to the next section and start from there. Otherwise follow these steps prior to starting the next section.

1. Launch the HATS Studio

2. From the HATS Welcome page , click on "launch the Create HATS Project Wizard" link.

3. The New Project panel will come up.

4.  Leave the check boxes checked (default) and click Next

5. On the Connection Settings panel enter the following:

6. The Select Default Template panel 7. When the studio finishes building the project files the HATS Project View will open and you will see the project folders on the left. Expand   the folders and examine the files that the studio build for the project. You can now go the next section to start customizing the HATS application.

HATS Global Variables

This section will introduce you to the HATS global variables. You will create a global variable which will extract the display number from the initial logon screen.
You will use this later in the application with a button that will appear to access the BOATS application.

1. With the project highlighted in the HATS Project View, click on the terminal icon from the toolbar. This will open the terminal window.
2. The initial screen should be the Sign On screen.

3. Press the "Create a HATS Screen Customization" icon from the terminal toolbar.
4. In the "Create a Screen Customization", enter "SignOn" for the name and press "Next".

5. Leave the selected Screen Recognition Criteria for the second wizard panel, and press "Next".

6. Select "Use existing transformation" with value of "default.jsp" checked, and check the "Add advanced action" check box, and press "Next".

7. Press the "Add" button on the "Advanced Actions" panel.

8. For the Action, select "Extract a global variable".

9. For the Name, enter "Display".

10. Draw a box over the Display ID to the right of the "Display . . . . :" text. Select OK.

11. Press the "Add" button again on the Advanced Actions panel.

12. Select the "Set a Global Variable" drop down.

13. Enter "localtime" for the variable name.

14. Press the "Set to a fixed value" radio button.

15. Enter 0 for the initial value. We will be updating this value using business logic in the next section. Press the OK button.

16. Press the Finish button in the "Create a Screen Customization" wizard.

Create a new business logic

1. Right click on the project, and select "New HATS -> Business Logic".

2. For the class name, enter LocalTime. For the package name, enter com.education.hats and press the Finish button.

3. You will see "LocalTime.java" open in the java editor with these contents:

4. Enter the new java code shown in the red box below. This code will query the current system time and set it to a HATS global variable.

5. Press Ctrl+S to save the java code. You should see no errors appear in the task list. When you save java files under WS/AD, it automatically compiles the code and places the associated class files in the appropriate directory for this WebApplication.

Create a Screen Customization to show the Global Variables

1. Open the terminal.

2. Logon to the first screen

3. Enter boats

4. Press Enter at the BOAT demo menu.

5. On the AS/400 WSG Boat Demo menu, press the customize icon.

6. Enter boatsdemo for the customization.

7. Press Next

8. Let the screen recognition criteria default, and press next.

9. Select to create a new transformation, boatsdemo.jsp

10. Select the "Add advanced actions" check box and press Next.

11. On the "Advanced Actions" dialog, press the Add button.

12. For the "Java package" entry field, press the "Browse..." Button and select com.education.hats

13. For the Class name entry field, enter LocalTime

14. For the method name, enter execute

15. Press the OK button

16. Press the Finish button on the "Create a Screen Customization" panel.

17. In the .jsp editor for the transformation, boatsdemo.jsp, select the Insert HATS component toolbar item .
18. Draw a box around the table of data in the "Screen Region" panel and press Next.

19. Leave the Default component and widget selected.

20. Press the Finish button.

21. In the source view of the boatsdemo.jsp editor, after the HATS:Component tag, enter the text for a line break <BR>

22. Place the cursor after the <BR> statement.

23. Select the drop down item of the Insert HATS component toolbar item, and select Insert Global Variable...
24. For the Name drop down, select the value localtime and press OK

25. Press Ctrl+S to save boatsdemo.jsp.

Restart the Server and Preview Customized Page

1. Select the Server Perspective by clicking on the icon on the left "Open Perspective" bar.
2. Select the "Servers" tab at the bottom of the screen.

3. Select the WebSphere v4.0 Test Environment server (the only one) and press the Restart icon on the title bar of the Servers window.
4. Wait for the text "Server Default Server open for e-business" to appear in the Console window.

5. If there is a Web Browser window open, close it.

6. Right click on the HATS project you created in the navigator window and click on the choice "Run on Server"

7. When the main menu screen appears, enter USER4BOATS for the User, password for the password, and press Enter.

8. If the main menu screen doesn't appear, press Enter.

9. See the modified screen with the new "View Boats" button.

Conclusion

In this tutorial you were shown how to use HATS business logic and global variables.