Passing arguments to an event handler

Related Topics ...

Overview: Handling Events

How to Use the Event Declaration Builder

We can pass arguments to an event handler by specifying that an event accepts arguments in the Event Declaration builder call and supplying those arguments when you call the fireEventName method.

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.

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");

  1. 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.

  2. 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);