Connecting Beans

In VisualAge, you draw connections between beans to define their interaction. This involves using the mouse to select a feature of the source bean and connect it to the feature of the target bean. The type of feature at the source--property or event--and the type of feature at the target--property, method, or code--determines the type of connection. For example, if the source is an event and the target is a method, the connection is an event-to-method.

If you decide to change the connection behavior of the bean, you can edit or reorder the existing connections without redrawing them.

Note:You can also perform connections within the Beans List window.

Connecting Features to Other Features

To connect two features, follow these steps. The term source refers to the where the connection begins and the term target refers to where the connection ends.

  1. Select the source bean, click mouse button 2, and select Connect from the pop-up menu.

    In most cases, a cascade menu appears that displays the names of the most commonly used (or preferred) features. If additional features exist that are appropriate for the connection type, Connectable Features also appears on the menu. Selecting Connectable Features opens a connection window with an expanded list of features, sorted alphabetically and by feature type.

  2. Select a feature by doing one of the following:

  3. If, at this point, you decide not to complete the connection, do one of the following:

    The menu or window closes without completing the connection.

  4. Place the mouse pointer over the target bean. As you move the mouse, a dashed line trails from the mouse pointer back to the source bean.

  5. Click mouse button 1. As with the source bean, either a pop-up menu or connection window appears.

  6. Select the target feature as before.

When you complete the connection, a colored connection line appears. The color indicates the connection type, based on the features you selected as end points.

You make connections within the beans list in the same manner as in the Visual Composition Editor. You cannot, however, start a connection on the Visual Composition Editor and complete it in the beans list or vice versa. You may want to draw connections on the beans list instead of the Visual Composition Editor if you use a layout that allows for a bean to completely cover another bean.

Note:If you are using an unbound property in a property-to-property connection, open properties on the connection and select an event to associate with the property. When the event is triggered, the properties values align.

Connecting Features to Code

The source for a code connection must be either an event or a bound property (a property that fires an event when its value changes). Connect to a code as follows:

  1. Open the pop-up menu for the source bean.
  2. Select Event to Code and the Event-to-Code Connection window appears.
  3. Select an Event from the Event drop-down.
  4. If you have already written the code, select it from the Method drop-down. Otherwise, leave <new method> visible in the Method field.
  5. Modify the code in the code window as appropriate. This window operates the same as the code window for creating methods in the IDE.
  6. If you want the event to pass its parameters to the new method, select Pass event data at the bottom of the panel.
  7. If the code takes input parameters and you want to specify them as constants, save the code by opening the code pane pop-up and selecting Save. When the code is saved, click Set parameters and enter the constants you want.
  8. Click OK.

    The connection window closes and VisualAge draws a green connection arrow from the source bean to a moveable text box on the free-form surface. If the connection arrow is dashed, you must supply values for the input parameters of the code.

    You can also create a code connection by selecting a source event and targeting an Event-to-Code Connection on the free-form surface.

Connecting from Connection Results

An exception is any user, logic, or system error detected by a function that does not deal with the error itself but passes the error on to a handling routine, called an exception handler. In VisualAge, you can catch exceptions by connecting exception events to either methods or code.

An exception is a feature of a connection, not a bean. It appears as exceptionOccurred on the connection's connection menu.

You can also pass the return value from the target of a connection. This return value displays as the normalResult event of the connection. You can connect the normalResult event to a feature of the same bean or another bean. For example, you can connect the exceptionOccurred to a method that brings up a prompter with an error message.

Supplying Parameter Values for Incomplete Connections

Connections sometimes require parameters, or input arguments. If a connection requires parameters that have not been specified explicitly or by default, it appears as a dashed arrow, indicating that it is incomplete. When you have made all the necessary parameter connections, the connection line becomes solid, indicating that the connection is complete.

You can create parameter from method and parameter from code connections. When the primary connection calls for a value parameter, it calls the method or code, which passes the return value as the parameter.

Supplying a Parameter Value Using a Connection

  1. Start a new connection using as the source, the dashed connection line that requires the parameter.

  2. For the target, select the feature that provides the value.

Supplying a Parameter Value Using a Constant

When connections need parameters with constant input values, provide these values through the properties window of the incomplete connection, as follows:

  1. Open properties for the incomplete connection by selecting Properties from the pop-up menu or by double-clicking the connection line. The properties window of the incomplete connection appears.

  2. Select Set parameters. The Constant Parameter Value Properties window appears showing the parameters for which you can set constant values.

  3. Enter the constant parameter values you want to use.

  4. Do one of the following:

Specifying Values for Parameters by Default

In most connections other than event-to-code, data is not passed by default from the source of a connection to the target. However, you can set VisualAge so that it always passes the available event data. In that case, the initial connection line may not appear dashed.

To set the connection to always pass event data, follow these steps:

  1. Open the properties for the connection.
  2. Select the Pass event data check box.
Note:The source of the connection determines the event data that is passed.

The event-to-code dialog defaults the Pass event data check box to false only if either of the following is not true:

Editing Connection Properties

Connection properties enable you to change a connection without redrawing it. Through the properties window, you can do the following:

To open properties for a connection from either the free-form surface or the Beans List window, move the mouse pointer over the connection and do one of the following:


Related concepts
Parameter Connections
Connections
Code Connections

Related procedures
Reordering Connections
Selecting and Deselecting Connections
Deleting Connections
Showing and Hiding Connections
Changing the Source and Target of Connections

Related references
Beans List
Pass Event Data
Event-to-Code Connection Window