Portlet Factory, Version 6.1.2


 

Passing arguments to an event handler

IBM® WebSphere Portlet Factory can pass arguments to an event handler by specifying that an event accepts arguments in the appropriate builder call and supplying those arguments when you call the fireEventName method. There are two kinds of events: standard events and widget events. To specify general events, use the Event Declaration builder call. For widget events, use the Widget Event builder call.

For standard events, configure the method specified by the Event Handler to accept arguments of the same number and type as those defined in the Event Declaration builder call. Your method can then process the arguments passed as needed.

For widget events, configure whether the widget fires, handles, or both fires and handles the events. For each widget, configure the Widget Event builder inputs to accept arguments of the same number and type as those defined in the widget that fires the events. Your method can then process the arguments passed as needed. No event handler is required.

For standard events, to pass arguments to an event handler:

  1. In the Event Declaration builder call, specify a name and type for each argument that you want to be able to pass to the action that handles the event.

  2. When you call the fireEventName method, supply the required arguments. For example: webAppAccess.fireMyEvent("CustomerName", "CustomerID");

  3. Configure the method that the Event Handler specifies as its action, to take the same number and type of arguments defined in the Event Declaration builder call. In this case, the method takes two arguments of type String.

  4. In the method, process the inputs according to your requirements. For example, you could store the customer name and id in two variables:
    ... webAppAccess.getVariables().setText("Customer_Name", arg1); webAppAccess.getVariables().setText("Customer_ID", arg2);

Parent topic: Overview: handling events


Library | Support |