34
Note
Script variable names used as a URL parameter must start with a capital x ("X")
Methods calling the event handler
To avoid event handlers calling each other an infinite number of times (which could result in runtime crashes),
events on components are only triggered by user interaction on the component and not by scripting. For example,
if a user swipes the pages of a pagebook, the On Select event is raised, and the relevant event script is executed.
In contrast, if the selected page index is set by script using the method setSelectedPageIndex of the pagebook,
the On Select event is not raised. Another example is if a user selects a value from a dropdown box, the On Select
event is raised and the event script is executed. In contrast, if the selected item is set using the setSelectedValue
method of the dropdown box, the event is not raised. However there are situations when you want to execute the
relevant event script without duplicating script code. In these cases, each component with an event (On Click, On
Select) has a corresponding method that allows the event handler to be called from another handler's code. For
example, the statement BUTTON_1.onClick(); calls the On Click event handler of the button component with
the name BUTTON_1. Another example is the statement TABSTRIP_1.onSelect(); that calls the On Select
event handler of the tabstrip component with the name TABSTRIP_1.
Example
You have created an application with a dropdown box DROPDOWN_1 and a button BUTTON_1. If the user
selects a value in the dropdown box, the selected value filters the dimension MYDIM in the data source aliases
DS_1 and DS_2. For this scenario, the On Select event script of the dropdown box looks like this:
DS_1.setFilter("MYDIM", DROPDOWN_1.getSelectedValue());
DS_2.setFilter("MYDIM", DROPDOWN_1.getSelectedValue());
If the user pushes the button, a specific value in the dropdown box should be selected programmatically using
the same logic defined for user interaction. In other words, the selected value filters the dimension MYDIM in
the data source aliases DS_1 and DS_2. Instead of duplicating the script code of the On Select event of
DROPDOWN_1, you add the following statements in the On Click event handler of the button:
DROPDOWN_1.setSelectedValue("MYDIMVALUE");
DROPDOWN_1.onSelect();
The benefits of calling the onSelect method increase as you start to work with more uses cases in the
application (where you want to set the selected value programmatically) and more statements in the On Select
event handler of the dropdown box.
130
© 2014 SAP AG or an SAP affiliate company. All rights reserved.
Application Designer Guide: Designing Analysis Applications
Scripting for User Interaction Enablement