Agent Events and Row Selection

In this Lesson

You will

  • Learn about agent events
  • Modify the solution to allow a party to be selected from the list.


Events are a named service offered by an agent. They exist to provide designers with an opportunity to request some service contained in an agent. For example, an agent could provide an event named approveShipment. The designer could then bind the event to a button which allows the customer to approve the shipment displayed in a scene. When the button is pressed the Soiree client sends the event name to the agent to initiate processing.

Each event has a name

  • Each name should clearly express the processing that will occur when the event is requested.
  • The name must follow the rules for a valid Java property. It must begin with a lower case character, $, or _ (underscore) and may not contain spaces or special characters.

Events may be defined in two different places within an agent’s scheme.

  1. Attached to a scheme
    These events are designed to provide agent level services.
  2. Attached to a row in a grid node
    These events are designed to provide row level services.

Standard Event Names
For agents that use a datasource Soiree can build the processing needed to service the following event names

  • delete
    • For single-row agents the event is attached to the scheme and is used to delete the information to which the agent is focused.
    • For multi-row agents the event is attached to rows in the list and is used to delete the information referenced by the row.
  • select
    • For multi-row agents it is attached to rows in the list and used to choose the information referenced by the row.
      Select Event
      The multi-row agent will publish the key of the selected row into the conversation context.

Custom Event Names
You may add any number of events to an agent for providing access to the specialized services contained in the agent.

Event Processing
Agents are provided with a method to handle each event. The name of the event handling method always starts with processEvent and is followed by the name of the event.

  • Events attached to the scheme produce a method that accepts no parameters. Example: processEventDelete()
  • Events attached to a grid row produce a method that accepts two parameters, a reference to the row on which the event was triggered, and the row’s zero based index within the grid. Example: processEvent_ListRowType1_Select(ListRowType1 row, int rowIndex)
    The method name contains the name of the grid node (List) the row type (RowType1) and the event name (Select).
  • Row Types
    Grid rows may contain many different types of rows and that capability will be described in a future lesson. The default name of the first row type is RowType1

Row Selection in a Multi-Row Agent

You will now go through the steps to enable row selection for the PartyList agent

Prepare the agent

  1. The agent must have a select method defined on the row. You do not need to make any changes because you provided the select event when you created the PartyList agent in a previous lesson as shown here

Prepare the scene

You will now modify the PartyDefinition scene as follows

  • Add a layer for viewing a party
  • Ensure the ‘view party’ layer is closed when a new party is being added
  • Open the ‘view party’ layer when a party is selected from the list
  • select event when the row is selected

Add a layer for displaying a party

  1. Open the PartyDefinition scene
  2. Pin layer 1

  3. Select layer 2 and then make a copy of it

  4. Double click the new layer’s thumbnail and change the name to view

  5. Right click the new layer’s thumbnail and remove the Modal setting

  6. Reposition the new layer and resize the layer(s) as needed so they can appear side by side as shown here
    • Change the title
    • Remove the Cancel button

  7. Right click the OK button and configure it to close the new layer

  8. Switch to the agent binding perspective and change the PartyTheme agent’s mode to view

  9. Change the Party agent’s mode to view

Ensure the view party layer is closed when a new party is being added

  1. Select layer 1
  2. Switch to the Design perspective
  3. Right click on the styled grid and configure its Add button to close the new layer

Open the view party layer when a party is selected from the list

  1. Right click on the row and configure its Left Click to open the new layer

Trigger the select event when the row is selected

  1. Switch to the Agent Binding perspective
  2. Drag the select event to the row in the styled grid.
    Drop it on the row – NOT on an element

  3. Click Pass-through
    When a mouse click occurs on a label that does not have an event bound to it – the client will pass the click through to the underlying container. So, by binding the event to the row the customer will be able to click anywhere on the row to select it. If the event was bound to an element they would have to click on the element to trigger the event.
  4. Right click on the row to see its binding properties

  5. Save the scene

Test the solution

  1. Start the solution
  2. Advance to the party list
  3. Select a party from the list. The party details layer should open and display the selected party

  4. You can select other another party while the view layer is open and its content will change to match the selected party.
    Open Layer Behavior
    An ‘open layer’ request will be silently ignored if the layer is already open.
  5. Notice all of the fields are not editable. This is the default behavior for agents in View mode.

  6. Click the OK button to ensure it closes the View layer
  7. Select another party to open the View layer
  8. Press the ‘add’ button at the bottom of the party list. The view layer should be closed when the create layer opens

This lesson is over.