What Happens at Runtime: How Client-Side Events Work

Handling Events 5-15 {}, false; } } The JavaScript contains the AdfCustomEvent.queue method that takes the event source, the string enterPressedOnSearch as the custom event type, a null parameter map, and False for the immediate parameter. The inputText component on the page also contains the following serverListener tag: af:serverListener type=enterPressedOnSearch method={explorer.navigatorManager. searchNavigator.searchOnEnter} Because the type value enterPressedOnSearch is the same as the value of the parameter in the AdfCustomEvent.queue method in the JavaScript, the method that resolves to the method expression {explorer.navigatorManager.searchNavigator.searchOnEnter} will be invoked.

5.4.1 How to Send Custom Events from the Client to the Server

To send a custom event from the client to the server, fire the client event using a custom event type, write the server listener method on a backing bean, and have this method process the custom event. Next, register the server listener with the component. To send custom events: 1. Create the JavaScript that will handle the custom event using the AdfCustomEvent.queue method to provide the event source, custom event type, and the parameters to send to the server. For example, the JavaScript used to cause the pressing of the Enter key to invoke the search functionality uses the AdfCustomEvent.queue method that takes the event source, the string enterPressedOnSearch as the custom event type, a null parameter map, and False for the immediate parameter, as shown in Example 5–13 . Example 5–13 Sample JavaScript for Custom Events Explorer.searchNameHandleKeyPress = function event { if event.getKeyCode==AdfKeyStroke.ENTER_KEY { var source = event.getSource; AdfCustomEvent.queuesource, enterPressedOnSearch, {}, false; } } 2. Create the server listener method on a managed bean. This method must be public and take an oracle.adf.view.rich.render.ClientEvent object and return a void type. Example 5–14 shows the code used in the SearchNavigatorView managed bean that simply calls another method to execute the search and then refreshes the navigator.