Visual bean builder code example

This example uses the IBM VisualAge Visual Composition Editor, but other visual bean builders are similar. This example creates an applet for a button that, when pressed, runs a command on an AS/400.

  1. Drag and drop a Button (Button1 in Figure 1) on the applet. (The Button can be found in the bean builder on the left side of the Visual Composition tab in Figure 1.)

  2. Drop a CommandCall bean and an AS400 bean outside the applet. (The beans can be found in the bean builder on the left side of the Visual Composition tab in Figure 1.)

Figure 1. VisualAge Visual Composition Editor window - gui.BeanExample.

  1. Edit the bean properties. (To edit, select the bean and then right-click to display a pop-up window, which has Properties as an option.)

    1. Change the label of the Button to Run command, as shown in Figure 2.

      Figure 2. Changing the label of the button to Run command.

    2. Change the system name of the AS400 bean to TestSys.

    3. Change the user ID of the AS400 bean to TestUser, as shown in Figure 3.

      Figure 3. Changing the name of the user ID to TestUser.

    4. Change the command of the CommandCall bean to SNDMSG MSG('Testing') TOUSR('TESTUSER'), as shown in Figure 4.

      Figure 4. Changing the command of the CommandCall bean.

  2. Connect the AS400 bean to the CommandCall bean. The method you use to do this varies between bean builders. For this example, do the following:

    1. Select the CommandCall bean and then click the right mouse button

    2. Select connect

    3. Select system

    4. Select the AS400 bean

    5. Select this from the pop-up menu that appears over the AS400 bean

  3. Connect the button to the CommandCall bean.

    1. Select the CommandCall bean and then click the right mouse button

    2. Select connect

    3. Select actionCompleted

    4. Select the CommandCall bean

    5. Select All features from the pop-up menu that appears

    6. Select run() from the list of methods as shown in Figure 5.

Figure 5. Connecting a method to a button.

When you are finished, the VisualAge Visual Composition Editor window should look like Figure 6.

Figure 6. Finished bean example


[ Legal | AS/400 Glossary ]