BEA Logo BEA Tuxedo Release 8.0

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

   Tuxedo Documentation   |   Using BEA Jolt   |   Local Topics   |   Previous Topic   |   Next Topic   |   Contents   |   Index

 


JoltBeans Class Library Walkthrough

This walkthrough describes how to build an applet that you use to:

The following figure shows an example of a completed Java form containing JoltBeans. The applet implements the client functionality for the INQUIRY service of the BANKAPP sample that is included with BEA Tuxedo. To run this sample, the BEA Tuxedo server must be running.

Sample Inquiry Applet


 
 

Refer to the figure Visual Café 3.0 Form Designer for an example of each item required by the Java form. Each item in that figure is described in the following table Required Form Elements.

Required Form Elements

Element

Purpose

Applet (or JApplet, if JFC applet is chosen)

A form used to paint the beans in your development environment.

JoltSessionBean

Logs on to a BEA Tuxedo session.

JoltTextField

Gets input from the user (in this case, ACCOUNT_ID).

JoltTextField

Displays the result (in this case, SBALANCE).

JoltServiceBean

Accesses a BEA Tuxedo service. (In this case, INQUIRY from BANKAPP).

Button

Initiates an action.

Label

Describes the field on the applet.


 

Building the Sample Form

The sample form is created using an integrated development environment (IDE), in this example, Visual Café 3.0. The example demonstrates how to build an applet that allows you to enter an account ID and use a BEA Tuxedo service to get and show the account balance.

Follow the basic steps below to create this sample.

  1. In Visual Café, choose File, New Project and select either JFC Applet or AWT application. This step provides you with the basic form designer on which you drop the JoltBeans.

  2. Drag and drop all of the JoltBeans you want to use in your applet from the Component Library onto the form designer.

  3. Modify or customize each bean using the property list or the custom property editor.

  4. Wire the beans together using the Interaction Wizard.

  5. Compile the applet.

These steps are described in detail in the following sections.

Note: The graphic interface of previous versions of Visual Café differ from the look of Visual Café 3.0. You can complete this sample applet in a previous version of Visual Café; however, the steps executed in the Interaction Wizard differ slightly from this example.

Placing JoltBeans onto the Form Designer

  1. Choose File, New Project, and choose JFC Applet.

  2. Drag and drop the beans from the Component Library (shown in the following figure) onto the palette of the form designer.

    JoltBeans and the Form Designer in Visual Café


     

The following figure Visual Café 3.0 Form Designer illustrates how JoltBeans appear when they are placed on the palette of the Form Designer.

Visual Café 3.0 Form Designer


 

  1. Set the properties of each bean. To modify or customize the buttons, labels or fields, use the property list. Some JoltBeans use a Custom Property Editor.

    The following figure,Example of JoltTextField Property List and Custom Property Editor, shows how selecting the JoltFieldName of the button property list displays the Custom Property Editor.

  2. Set the properties of the beans (for example, set the JoltFieldName property of the JoltTextField to ACCOUNT_ID).

Note: For complete information on setting and modifying the properties of the JoltBeans, refer to Using the Jolt Repository and Setting the Property Values.

The following table specifies the property values that should be set. Values specified in bold and italic text are required, and those in plain text are recommended.

Required and Recommended Property Values

Bean

Property

Value

label1

Text

Account ID

label2

Text

Balance

JoltTextField1

Name

accountId

JoltTextField1

JoltFieldName

ACCOUNT_ID

JoltTextField2

Name

balance

JoltTextField2

JoltFieldName

SBALANCE

JoltSessionBean1

AppAddress

//tuxserv:2010

JoltServiceBean1

Name

inquiry

JoltServiceBean1

ServiceName

INQUIRY

button1

Label

Inquiry


 

Note: In this walkthrough, the default occurrenceIndex of 0 works for both JoltTextFields.

Refer to the following figure Example of JoltTextField Property List and Custom Property Editorand Using the Jolt Repository and Setting the Property Values for general guidelines about JoltBean properties.

Example of JoltTextField Property List and Custom Property Editor


 
 

  1. To change the value of the JoltFieldName property, click on the ellipsis button of the JoltFieldName in the Property List.

    The Custom Property Editor is displayed.

  2. Select or type the new field name (in this example, "ACCOUNT_ID") and click OK.

    The change is reflected in the Property List shown in the following figure Revised JoltFieldName in the JoltTextField Property Listand on the text field shown on the figure Example of JoltBeans on the Form Designer with Property Changes.

Note: The properties that are visible in the Custom Property Editor are cached locally; therefore, if the source database is modified you must use the Refresh button to see the current, available properties.

Revised JoltFieldName in the JoltTextField Property List


 
 
 

The following figure Example of JoltBeans on the Form Designer with Property Changes illustrates how the text on the button and the textfield changes after the text is added to the property list fields for these beans.

Example of JoltBeans on the Form Designer with Property Changes


 
 
 
 

  1. After you set the properties to the right values (refer to the table Required and Recommended Property Values for additional information), define how the beans will interact by wiring them together using the Visual Café Interaction Wizard. Refer to "Wiring the JoltBeans Together" for details.

Wiring the JoltBeans Together

After all the beans are positioned on your form and the properties are set, you must wire the beans and their events together. The following figure Sequence in Which JoltBeans Are Wired illustrates an example of the flow to help you determine the correct order in which to wire the beans.

Wiring the beans allows you to establish event source-listener relationships between various beans on the form. For example, the JoltServiceBean is a listener of ActionEvents from the button and invokes callService() when the event is received. Use the Visual Café Interaction Wizard to wire the beans together.

The following figure shows the sequence in which you will wire the beans together to create this sample applet. The numbers in this figure correspond to the numbered steps that follow.

Sequence in Which JoltBeans Are Wired


 

The steps below correspond to the callouts shown in the figure Sequence in Which JoltBeans Are Wired. Each of the steps below is detailed in the sections that follow.

Step 1: Wire the JoltSessionBean Logon

Step 2: Wire JoltSessionBean to JoltServiceBean Using PropertyChange

Step 3: Wire the accountID JoltTextField as Input to the JoltServiceBean Using JoltInputEvent

Step 4: Wire Button to JoltServiceBean Using JoltAction

Step 5: Wire JoltServiceBean to the Balance JoltTextField Using JoltOutputEvent

Step 6: Wire the JoltSessionBean Logoff

Step 7: Compile the Applet (not shown as a callout)

Step 1: Wire the JoltSessionBean Logon

  1. In the Form Designer window, click the Interaction Wizard button.

  2. Click in the applet window and drag a line to the JoltSessionBean as shown in the following figure.
     
     

    Wire the Applet to the Jolt Session Bean


     

The Interaction Wizard window is displayed as shown in the figure Select ComponentShown Event, with the prompt:

What event in JApplet1 do you want to start the interaction?

  1. Select componentShown in the Interaction Wizard window as the event with which you want to start the interaction, as shown in the following figure.

    Select ComponentShown Event


     
     
     
     
     
     

  2. Click Next.

    The Interaction Wizard window is displayed, as shown in the figure Select Logon to the Tuxedo System Action, with the prompt:

    What do you want to happen when Japplet1 fires componentShown event?

  3. With the Perform an action radio button enabled, select the action Logon to the TUXEDO system, as shown in the following figure.

    Select Logon to the Tuxedo System Action


     

  4. Click Finish.

Completing "Step 1: Wire the JoltSessionBean Logon" enables the logon() method of the JoltSessionBean to be triggered by an applet (for example, ComponentShown) that is sent when the applet is opened for the first time.

Step 2: Wire JoltSessionBean to JoltServiceBean Using PropertyChange

  1. Click the Interaction Tool icon in the toolbar of the Visual Café Form Designer window to display the bean components.

  2. Click on the JoltSessionBean and drag a line to the JoltServiceBean, as shown in the following figure.

    Wire the JoltSessionBean to the JoltServiceBean


     

The Interaction Wizard window is displayed as shown in the figure Select propertyChange Event, with the prompt:

What event in joltSessionBean1 do you want to start the interaction?

  1. Select propertyChange as the event that starts the interaction, as shown in the following figure.

    Select propertyChange Event


     

  1. Click Next.

    The Interaction Wizard window is displayed as shown in the figure Select Handle a Jolt property change event..., with the prompt:

    What do you want to happen when joltSessionBean1 fires propertyChange event?

  2. Select Handle a Jolt property change event as the method, as shown in the following figure.

    Select Handle a Jolt property change event...


     

  3. Click Next.

    The Interaction Wizard window is displayed as shown in the figure Select joltSesssionBean, with the prompt:

    How do you want to supply the parameter to this method?

    and a list of available objects and actions from which to choose.

  4. Select joltSessionBean1 as the object that supplies the action, as shown in the following figure.

  5. Select Get the current Property Change Event object as the action, also as shown in the following figure.

    Select joltSesssionBean1


     

  6. Click Finish.

Completing "Step 2: Wire JoltSessionBean to JoltServiceBean Using PropertyChange"enables the JoltSessionBean to send a propertyChange event when logon() completes. The JoltServiceBean listens to this event and associates its service with this session.

Step 3: Wire the accountID JoltTextField as Input to the JoltServiceBean Using JoltInputEvent

  1. Click the Interaction Wizard icon in the Visual Café Form Designer window.

  2. Select the accountID JoltTextField bean and drag a line to the JoltServiceBean.

    The Interaction Wizard window is displayed, as shown in the following figure, with the prompt:

    What event in accountId do you want to start the interaction?

  3. Select dataChanged as the event, as shown in the following figure.

    Select dataChanged Event


     

  4. Click Next.

    The Interaction Wizard window is displayed as shown in the figure Select inquiry Object and Handle a Jolt input event Action, with the prompt:

    What do you want to happen when accountId fires dataChanged event?

  5. Select the joltServiceBean inquiry as the object supplying the parameter, as shown in the following figure.

  6. Select Handle a jolt input event as the action, also as shown in the following figure.

    Select inquiry Object and Handle a Jolt input event Action


     

  7. Click Next.

    The Interaction Wizard window is displayed as shown in Select accountId Object and Get the current Jolt Input Event Action, with the prompt:

    How do you want to supply the parameter to this method?

    and a list of available objects and actions from which to choose.

  8. Select accountId as the object, as shown in the following figure.

  9. Select get the current Jolt Input Event as the action, also as shown in the following figure.

    Select accountId Object and Get the current Jolt Input Event Action


     

  10. Click Finish.

Completing "Step 3: Wire the accountID JoltTextField as Input to the JoltServiceBean Using JoltInputEvent" enables you to type the account number in the first text field. The JoltFieldName property of this JoltTextField is set to "ACCOUNT_ID". Whenever the text inside this text box changes, it sends a JoltInputEvent to the JoltServiceBean. (The JoltServiceBean listens to JoltInputEvents from this text box.) The JoltInputEvent object contains the name, value, and occurrence index of the field.

Step 4: Wire Button to JoltServiceBean Using JoltAction

  1. Click the Interaction Wizard icon in the Visual Café Form Designer window.

  2. Click the Inquiry Button and drag a line to the JoltServiceBean.

    The Interaction Wizard window is displayed as shown in the following figure, with the prompt:

    What event in button1 do you want to start the interaction?

  3. Select actionPerformed as the event, as shown in the following figure.

    Select action Performed Event


     

  4. Click Next.

    The Interaction Wizard window is displayed, as shown in the figure Select inquiry Object and Invoke the TUXEDO Service... Action, with the prompt:

    What do you want to happen when button1 fires actionPerformed event?

  5. Select inquiry as the object, as shown in the following figure.

  6. Select Invoke the TUXEDO Service represented by this Bean as the action, also as shown in the following figure.

    Select inquiry Object and Invoke the TUXEDO Service... Action


     

  7. Click Finish.

Completing "Step 4: Wire Button to JoltServiceBean Using JoltAction" enables the callService() method of the JoltServiceBean to be triggered by an ActionEvent from the Inquiry button.

Step 5: Wire JoltServiceBean to the Balance JoltTextField Using JoltOutputEvent

  1. Click the Interaction Wizard icon in the Visual Café Form Designer window.

  2. Select the JoltServiceBean and drag a line to the AmountJoltTextField bean.

    The Interaction Wizard is displayed, as shown in the following figure, with the prompt:

    What event in inquiry do you want to start the interaction?

  3. Select serviceReturned as the event, as shown in the following figure.

    Select ServiceReturned Event


     

  4. Click Next.

    The Interaction Wizard window is displayed, as shown in the figure Select balance Object and Handle a service returned event Action, with the prompt:

    What do you want to happen when inquiry fires serviceReturned event?

  5. Select balance as the object, as shown in the following figure.

  6. Select Handle a service returned event... as the action, also as shown in the following figure.

    Select balance Object and Handle a service returned event Action


     

  7. Click Next.

    The Interaction Wizard window is displayed, as shown in the figure Select inquiry Object and Get the JoltOutputEvent object Action, with the prompt:

    How do you want to supply the parameter to this method?

  8. Select inquiry as the object, as shown in the following figure.

  9. Select Get the JoltOutputEvent object as the action, also as shown in the following figure.

    Select inquiry Object and Get the JoltOutputEvent object Action


     

  10. Click Finish.

Completing "Step 5: Wire JoltServiceBean to the Balance JoltTextField Using JoltOutputEvent"allows the JoltServiceBean to send a JoltOutputEvent when it receives reply data from the remote service. The JoltOutputEvent object contains methods to access fields in the output buffer. The JoltTextField displays the result of the INQUIRY service.

Step 6: Wire the JoltSessionBean Logoff

  1. Click the Interaction Wizard icon in the Visual Café Form Designer window.

  2. Click in the applet window (not on another bean) and drag a line to the JoltSessionBean.

    The Interaction Wizard is displayed, as shown in the following figure, with the prompt:

    What event in JApplet1 do you want to start the interaction?

  3. Select componentHidden as the event, as shown in the following figure.

    Select componentHidden Event


     

  4. Click Next.

    The Interaction Wizard window is displayed, as shown in the figure Select joltSessionBean1 Object and Logoff from the Tuxedo System Action, with the prompt:

    What do you want to happen when JApplet1 fires componentHidden event?

  5. Select joltSessionBean1 as the object, as shown in the following figure.

  6. Select Logoff from the TUXEDO system as the action, also as shown in the following figure.

    Select joltSessionBean1 Object and Logoff from the Tuxedo System Action


     

  7. Click Finish.

Completing "Step 6: Wire the JoltSessionBean Logoff" enables the logoff() method of the JoltSessionBean to be triggered by an applet (for example, componentHidden) that is sent when the applet gets hidden.

Step 7: Compile the Applet

After wiring the JoltBeans together, compile the applet. It is also recommended that you fill in the empty catch blocks for exceptions. Check the message window for any compilation errors and exceptions.

For additional information see the following section "Using the Jolt Repository and Setting the Property Values." Also refer to the table JoltBean Specific Properties and the figure JoltServiceBean Property Editor.

Running the Sample Application

To run the sample application, you must have the BEA Tuxedo server running. Then enter an account number in the Account ID textfield. You can use any of the account numbers included in the BANKAPP database. Following are two examples of account numbers you can use to test the sample application:

 

back to top previous page next page