The focus of this section is to finish developing your user interface and connect it to a server application that reads data to be displayed in the Customer Information window. The objective of this section is to familiarize you with making connections between user interfaces and nonvisual parts, such as records and server applications. In addition, you will build the server application and embed the Address panel you created in the previous section. Finally, you will use the interactive test facility to test how the client and server applications work together.
You can now complete the window in Figure 92, which displays detailed customer information.
Figure 92. Customer Information Window
To complete the window, add the Address panel you created in Defining the address panel to the Customer Information Window. To add the reusable visual part, perform the following steps:
The Composition Editor opens, displaying the Customer Information window.
The Choose bean window is displayed
The mouse pointer becomes a cross hair.
Tip: | Alternatively, you can select the Browse button and select the class name from the displayed list. The package name is automatically appended for you. |
The Address panel is added to the Window.
The Start connection from window is displayed.
A dotted line with a
at the end is displayed.
The End connection to window is displayed.
This creates a property-to-property connection between the Street entry field and the data item CUSSTREET in the CUSTOMER Record part.
By selecting the data property, you are making a connection to only the data contents of the data item. If the connection required a type description in addition to the data contents, you would have selected CUSSTREET, which represents the this property of the data item.
The entry fields in windows, as in this example, typically only require the data contents. However, when you connect to a parameter in a called parameter list for a program, the data contents and the type description are required.
This creates property-to-property connections between the fields in the panel and the data items in the CUSTOMER Record part. If you want to check any of the connections, select the connection and the status area will contain a description of it.
Now that all the user interface parts are in place on the Window, you'll add a VAGen Program part to the free-form surface and connect it to the Find button. The VAGen Program part represents a server program that you will define later in this exercise. The server program will read the customer details from the database and return the data to TutorialView to populate the fields in the Customer Information window.
A graphical list of VAGen parts is shown on the Beans palette.
The Add Part window is displayed.
The FINDCUS program part is now on your free-form surface.
The context menu for the Find button is displayed.
A line with a
on the end is displayed.
A context menu is displayed.
A green line with an arrow now connects the Find button with the FINDCUS program part. This connection means that when the Find button is clicked, FINDCUS is called.
A context menu is displayed
The New Part Package window is displayed
The Program Editor opens to display FINDCUS.
In this section you define the VAGen server application FINDCUS, which reads the customer information from a relational database. To retrieve the correct customer information, the record key (CUSNUM) for the database must be passed to the server application from TutorialView. To display the retrieved information, the data to populate the Customer Information window must be returned from the server application. Parameters are the mechanisms by which data is passed between applications.
To define the server application, in the Program Editor, perform the following steps:
The Insert Parameter window is displayed.
The CUSTOMER record is displayed in the program diagram under Called Parameters. Now you are ready to define the main functions for FINDCUS.
The Insert Main Function window is displayed.
The FIND-CUSTOMER function is displayed in the structure diagram. The ? beside it means that it has not yet been defined.
The New Part Package window is displayed.
The Function Editor is displayed.
The I/O option and I/O object are displayed on the second line in the Function Editor.
The Function Properties window is displayed.
The Function Properties window closes. The information retrieved from the database inquiry will be placed in the CUSTINFO record you will define later. The error routine EZERTN will return control to your application when an error occurs. This prevents the application from ending with system generated messages, which might confuse an application user.
The first statement executes before the actual database query. The other statements execute after the query takes place.
custinfo.cusnum = customer.cusnum; /*customer number to be retrieved ----------------------- INQUIRY CUSTINFO --------------------- if custinfo not err; /*If the query did not return an error customer = custinfo; /*Place all data from the retrieved end; /*row into the customer record
The statements have been validated and formatted. If a Validation Errors window is displayed, correct the errors listed in the window, and select Validate and Format again.
A + is displayed beside the FIND-CUSTOMER function in the Program Editor.
In the previous section, you defined an INQUIRY function that uses the CUSTINFO record. Now, you need to define the record. This record will contain the detailed customer information after it is retrieved from the database.
The CUSTINFO record is displayed.
The Record Editor is displayed.
The SQL Row Properties window is displayed.
A row is added and the cursor appears in the Name pane.
The SQL Row Properties window closes.
The SQL table is displayed in the Record Editor.
The check box is checked. The CUSNUM item is defined as the key data item.
The fully-defined CUSTINFO record is displayed in the Program Editor.
In this section you build the parameters that will be passed between the client view and the FINDCUS program. You also visually connect the parameters to complete the definition.
Based on the parameter list of FINDCUS, this action creates the parameters needed for the CALL.
Selecting Build parameters from definition causes defined parameters to be added to the execute method of the FINDCUS program part. The solid green line changes to a dashed green line and a statement displayed in the status line confirms that default parameters were built.
You now have a line with a
on the end.
A context menu is displayed.
A purple line is displayed connecting the CUSTOMER record to the FINDCUS program. The dashed green becomes solid
A property-to-property connection connects the CUSTOMER parameter of FINDCUS to the CUSTOMER record. You selected the this property to pass the data contents and the type description of the record to the server application.
Your completed server application should look like Figure 104
For more information on building visual parts, refer to the VisualAge for Java online help.
Now test your bean using the Interactive Test Facility.
The Customer Information window is displayed.
If you want Test Monitor to have focus while it tests your VAGen parts, VAGen Parts Browser, select Window>Options. On the VAGen Test window, under options, select Break on event entry for GUI clients.
Start the Test Monitor. The Test Monitor gets focus if you have an error in a VAGen part. If you would like to see the Test Monitor window throughout your test run, move it to the right side of your screen.
If errors are encountered during the test, you can change your code without leaving the test. After you make changes and save the part, the test facility automatically repositions the test for you to test your new changes.
Otherwise, the program runs and the Customer Information window is updated with data from the database. Your application ran successfully if it looks like the one shown in Figure 96.
The Customer Information window closes.
Figure 96. Customer Information Window
Congratulations! You have completed all the steps in this tutorial, and you have experienced first-hand how easy it is to define and test applications using VisualAge Generator. As you begin working with VisualAge Generator, you can refer back to this tutorial, all the other VisualAge Generator documentation, and VisualAge Generator's extensive online help system.