setEventMappingEx

setEventMappingEx(eventMethod: Method;
                  mappedMethod: Method);

The setEventMappingEx method of the MenuItem class enables the method that is to be executed for an event to be dynamically set at run time and the mapping cached on each JADE node. (See also the setEventMappingEx method of the Window class.)

An exception is raised if a MenuItem method is invoked from a server method.

Repeat calls for a mapping that has been previously used is recognized and the signature check is not repeated unless the timestamp of the mapped method has changed since the previous signature check. The cost of reloading a form that assigns event mappings is therefore subsequently less expensive on that node. If an application server is involved, only the first assignment by any user performs the signature check. Subsequent repeat calls for any user on that application server avoid that overhead.

The event method being mapped and the mapped method are passed as parameters. The underlying logic, therefore, does not have to find the methods by name, making the execution more efficient; for example:

mnuCustomer.setEventMethodEx(MenuItem::click, CustomerDialog::customerMenu);

This method is equivalent to the setEventMapping method but as it is more efficient, you should use the setEventMappingEx method to improve performance.

The parameters of the setEventMappingEx method are listed in the following table.

Setting Description
eventMethod Specifies the event method, which must belong to the class of the receiver of the setEventMappingEx call, and must be a defined event name for the menu; for example, click.
mappedMethod The method that is to be called. This method must exist on the form that is the parent of the menu or window for which you are calling the setEventMappingEx.

The code fragment in the following example shows the use of the setEventMappingEx method.

mTickerTimer.setEventMapping(Button::click, MyForm::myOtherMenu);

The method checks that: