This is an example of how to use WebSphere Host Publisher to connect, collect data, and disconnect from a University site. Using Host Access, we will connect to the University of Michigan's Library database. From this database we can search for books by authors, titles, subjects, and so on. We will search for books by the author's name. After we obtain a list of books, we will disconnect from the database. This example will be used as a basis for the following examples: Conditional Looping and Chaining.
Creating and Understanding the Connection Macro
When you define a Host Integration Object, a Java bean that encapsulate interactions with data sources and return desired data as Java bean properties, you must define a Connect Macro, and additionally, a Disconnect Macro. You can configure a default connection pool that does not use pooling and has the same name you chose for your Integration Object. Alternatively, you can create and use a new pool, or use an existing connection pool. You have three choices:
Create a new pool
Select this option if you want to define a new
connection and connection pooling information. Connection pooling
keeps one or more connections to the host initialized, which reduces the
response time between when a client browser requests information and when
the information displays on a Web page. If you do not use connection
pooling, your Integration Object connects to the host each time you request
a connection.
You can use one of several user accounts, but it is not necessary. Ensure that each of the IDs you specify behave the same way as the ID you use to record the macros; otherwise your Connect Macro might not run correctly when other user IDs from the pool are used.
Share an existing pool
Select this option to specify which existing
pool to use. When you select Share an existing pool, Host Access
uses the host server information associated with that pool.
When you create a connection pool, the Connect and Disconnect Macros are associated with that pool. When you create an Integration Object, you use a pool created as part of that Object. Although it may look as if you are recording the Connect and Disconnect macros as part of the object, they are really kept separate. When you record subsequent Integration Objects, you can create a new connection that requires you to record Connect/Disconnect Macros, or you can use an existing connection pool that associates the Object with existing Connect and Disconnect Macros.
Creating the Connect Macro
When the Host Access application is initially brought up, the Welcome screen appears. Click Next.
The Integration Object screen appears. Select Create a new Integration Object, then click Next.
The Host Configuration screen appears. You now have the option to Configure a default connection pool, Create a new pool, or Share an existing connection pool. We will Configure a default connection pool. Fill in the Server name and Terminal type of the University of Michigan's host in the Host Server Information box. After you complete the Host Configuration page, click Next.
You are ready to begin recording the Connect Macro. Click Next.
The New Screen Definition screen appears. You must define the first screen in each macro. The screen name defaults to Screen1, Screen2, and so forth. To make the macro easier to read, change the name to something meaningful. If this screen appears at different times in the Macro and requires the same action each time, select This is a global screen. You cannot use a global screen as the last screen in a Macro.
In this example, we rename the screen to Database Selection Menu Screen which makes the screen easier to identify on the left-hand side. Click Next.
The Add Recognition Criterion to Screen Definition appears. This page allows you to choose how you want the Integration Object to remember this screen. Text area allows you to choose specific text on the screen, Number of fields allows you to choose the number of total fields on the screen or the number of input fields, Cursor position allows you to recognize the screen by the position of the cursor, and then there is an Advanced choice that you can read about in Help. Remember that you must uniquely define each screen. For this example, we are going to select Advanced choice, Color at cursor position, and click Next. This will allow us to recognize the screen by the color at a single location.
The Color at Cursor Position screen appears. For this screen we are going to choose the D in Database Selection located in the lower left-hand corner of the screen. This was chosen to ensure that when you create the web application in Host Publisher Studio, that the screen is going to be fully painted onto the screen to establish that the application is viewing the correct screen. The information located in the boxes is immediately filled in when you choose the cursor position. Click Next.
The Screen Definition screen appears. This screen allows you to add additional criteria for recognizing a screen should you choose to do so. Click Add to choose additional criteria for recognizing this screen.
The Add Recognition Criterion to Screen Definition appears. Select Text area and click Next.
The Text Area Recognition screen appears. We will recognize this logon screen by drawing a box, using the cursor, around Database Selection Menu, which is located near the top of the screen. This allows you to recognize the screen by the unique text that you selected. Select the At the specified position option, and click Next.
The Screen Definition appears. The different criteria that you have chosen to recognize the screen by appears in the table. Click Next.
You have now completed the Connect Macro. The wizard states that when you are ready to move to the Data Macro, click Next. We are going to begin recording our Data Macro and gather data. Click Next.
Creating the Data Macro
The Data Macro is where the system starts recording the steps you take to obtain the desired data.
The Begin Data Macro screen appears. In this example, we are going to collect data, so select Gather Data and click Next.
We will navigate to the point where we want to capture data. Enter the database selection "MCAT" in capital letters then press the Enter key.
The Unrecognized Screen appears. Click Yes to create a definition for this screen.
The New Screen Definition screen appears. Rename the screen from Screen2 to Introduction Screen, then click Next.
The Add Recognition Criterion to Screen Definition appears. For this example, we are going to select Text area and click Next.
The Text Area Recognition screen appears. Draw a box around the specified text on the terminal. In this case, it is the word Introduction in the upper right-hand corner of the screen. Select At the specified position and click Next.
The Screen Definition appears. Click Next.
The Gather Data Screen appears. In this example, we will extract the names of books by a particular author. By selecting to use a variable for the author, you can fill in different names during invocations of the Data Macro. Type a=, then click Insert Input Variable. (You may use the Menu item pull downs, or use the Insert Input Variable item on the tool bar.)
The Insert Input Variable box appears. Type an input variable name, and provide a value for the variable, which will be used only to record the interaction with this system. The value itself will not be remembered.
In this example, the variable will be author. For recording purposes, we fill in a temporary value for the author. Since this value is variable, the value is not stored in the Integration Object. It is merely used to continue recording. After typing this information, click OK.
Note that the value used for the variable is inserted in the command line. Press Enter to continue recording this data.
The Unrecognized Screen appears. Create a definition for this screen by selecting Yes.
The New Screen Definition screen appears. We will rename this screen from Screen3 to Search Results Screen. Click Next.
The Add Recognition Criterion to Screen Definition appears. For this example, we are going to select Text area and click Next.
The Text Area Recognition appears. Draw a box around the words Search Results and select At the specified position, then click Next.
The Screen Definition appears. Click Next.
The Gather Data Screen appears. You are now ready to capture data associated with this page. Click Next.
The Select Data page appears. Select Select data on the terminal and draw a box around the data you want to capture. When you finish, click Next.
The Data Format page appears. We can choose to display the information in the selected area as text, or provide it to the user in a table format. In this example, the data will appear as a table. Select Extract data as a table, then click Next.
The Extract Data page appears. Type a name for this extraction, then click Next.
The Select Column Names page appears. You can either use values on the screen as table headers by selecting text on the screen, or use default values by selecting Next. You can change these names when you use the Studio. Therefore, let the table header names default and click Next.
The Data Table appears. Select the column name and provide an identifiable value. In this example, the header was allowed to default to column0, which we changed to book_titles. To change the column name, select the column, then type the new name in the text box, Column name. You can also modify the column width. After all the values are provided for all of the column headers, click Next.
The Finish Data Extraction page appears. Select Finished extracting data, then click Next.
The Finish Data Macro screen appears. Navigate back to the Database Selection Menu Screen by typing STA and press Enter to disconnect from the session.
The Finish Data Macro screen appears. You are now ready to begin recording the Disconnect Macro. Click Next.
Creating the Disconnect Macro
The Disconnect Your Session screen appears. Disconnect from the session by typing "exit" and press Enter. Look at the left-hand side. The key strokes you entered to disconnect from the session are recorded in the Disconnect Macro. Since you are disconnected from the system, click Next.
The Save Integration Object screen appears. Click Next to save this Integration Object (or use the File->Save menu).
You are asked to name this Integration object. Enter the name (leaving off the file extension) and click Save.
The Integration Object is being generated. When complete, click OK. You have now created Connect, Data, and Disconnect Macros. You are finished! You are ready to use the Host Publisher Studio to build an application to deploy to Host Publisher servers. For details on how to build the Web Application go to Host Publisher Studio: Basic Example .