Creating and Editing an Event

While editing an entity object with the Entity Object Editor, you can use the Publish page to create and edit events to be published by the entity object. An event is raised by invoking the event method in custom Java code. Enter or edit the event's name and parameters that should be delivered. Ordering of these parameters is not necessary, as the event delivers the parameters in a hashtable, hashed by the parameter name. The editor generates event code in the Java files for the entity object class and the entity definition class, as well as XML code, so the entity object can publish the event.

To add an event:

  1. In the Publish page, click New.

  2. In the Create New Event dialog, type an event name in the Name field.

  3. To deliver an attribute with the event, select one or more attributes in the Available Attributes list and click > to move them to the Selected Attributes list.

    You can control-click to move more than one attribute or use the >> button to select all the attributes. Select an attribute and click > to remove it from the selected list or click >> to remove all selected attributes.

  4. Click OK.

    The event appears in the Published Events list of the Publish page.

  5. To make this event immediately available in the following Subscribe page, click Apply when you are finished with this page.

To edit an event:

  1. In the Publish page, select the event in the Published Events list.

  2. Click Edit.

  3. In the Edit Event dialog, edit the name or the attributes delivered with the event.

  4. Click OK.

To send an event:

The editor generates a method of the same name as the event. You must add a call to this method from whatever code fires the event.

For example, for an event named SalaryChanged, the generated method is also named SalaryChanged(). Any call to SalaryChanged fires the event, sending the appropriate data. To fire the SalaryChanged event whenever Sal is set, call SalaryChanged from setSal.

public void setSal(Number value) {
setAttributeInternal(SAL, value);
SalaryChanged(); // Call this method to fire the event.
}