Using ADF Faces Server Events

Handling Events 5-5 setSelectedFileItemdata; } 2. To register an event listener method on a component, in the Structure window, select the component that will invoke the event. In the Property Inspector, use the dropdown menu next to the event listener property, and choose Edit. 3. Use the Edit Property dialog to select the managed bean and method created in Step 1. Example 5–2 shows sample code for registering a selection event listener method on a table component. Example 5–2 Registering an Event Listener Method af:table id=folderTable var=file . . . rowSelection=single selectionListener={explorer.tableContentView.tableSelectFileItem} . . . af:table

5.3 Using JavaScript for ADF Faces Client Events

Most components can also work with client-side events. Handling events on the client saves a roundtrip to the server. When you use client-side events, instead of having managed beans contain the event handler code, you use JavaScript, which can be contained either on the calling page or in a JavaScript library. By default, client events are processed only on the client. However, some event types are also delivered to the server, for example, AdfActionEvent events, which indicate a button has been clicked. Other events may be delivered to the server depending on the component state. For example, AdfValueChangeEvent events will be delivered to the server when the autoSubmit attribute is set to true. You can cancel an event from being delivered to the server if no additional processing is needed. However, some client events cannot be canceled. For example, because the popupOpened event type is delivered after the popup window has opened, this event delivery to the server cannot be canceled. Tip: If the event listener code is likely to be used by more than one page in your application, consider creating an event listener implementation class that all pages can access. All server event listener class implementations must override a processEvent method, where Event is the event type. For example, the LaunchListener event listener accepts an instance of LaunchEvent as the single argument. In an implementation, you must override the event processing method, as shown in the following method signature: public void processLaunch LaunchEvent evt { your code here } 5-6 Web User Interface Developers Guide for Oracle Application Development Framework Table 5–3 lists the events generated by ADF Faces client components, whether or not events are sent to the sever, whether or not the events are cancelable, and the components that trigger the events. Performance Tip: If no server processing is needed for an event, consider canceling the event at the end of processing so that the event does not propagate to the server. For more information, see Section 5.3.5, How to Prevent Events from Propagating to the Server. Table 5–3 ADF Faces Client Events Event Type Event Class Propagates to Server Can Be Canceled Triggered by Component action AdfActionEvent Yes Yes All command components dialog AdfDialogEvent Yes Yes dialog When user selects the OK or Cancel button in a dialog disclosure AdfDisclosureEvent Yes Yes showDetail, showDetailHeader, showDetailItem When the disclosure state is toggled by the user AdfFocusEvent Yes Yes tree, treeTable AdfLaunchPopupEvent Yes Yes inputListOfValues, inputComboboxListOfValue s inlineFrameLoad AdfDomComponentEvent Yes Yes inlineFrame When the internal iframe fires its load event. load AdfComponentEvent Yes Yes document After the document’s contents have been displayed on the client, even when PPR navigation is used. It does not always correspond to the onLoad DOM event. AdfPollEvent Yes Yes poll popupOpened AdfPopupOpenedEvent No No popup After a popup window or dialog is opened popupOpening AdfPopupOpeningEvent No Yes popup Prior to opening a popup window or dialog popupClosed AdfPopupClosedEvent No No popup After a popup window or dialog is closed propertyChange AdfPropertyChangeEvent No No All components query AdfQueryEvent Yes Yes query, quickQuery Upon a query action that is, when the user clicks the search icon or search button Handling Events 5-7 ADF Faces also supports client keyboard and mouse events, as shown in Table 5–4 queryOperation AdfQueryOperationEvent Yes Yes query, quickQuery AdfReturnEvent Yes Yes All command components AdfReturnPopupDataEvent Yes Yes inputListOfValues, inputComboboxListOfValue s AdfReturnPopupEvent Yes Yes inputListOfValues, inputComboboxListOfValue s rowDisclosure AdfRowDisclosureEvent Yes Yes tree, treeTable When the row disclosure state is toggled selection AdfSelectionEvent Yes Yes tree, treeTable, table When the selection state changes sort AdfSortEvent Yes Yes treeTable, table When the user sorts the table data valueChange AdfValueChangeEvent Yes Yes All input and select components components that implement EditableValueHolder When the value of an input or select component is changed Table 5–4 Keyboard and Mouse Event Types Supported Event Type Event Fires When... click User clicks a component dblclick User double-clicks a component mousedown User moves mouse down on a component mouseup User moves mouse up on a component mousemove User moves mouse while over a component mouseover Mouse enters a component mouseout Mouse leaves a component keydown User presses key down while focused on a component keyup User releases key while focused on a component keypress When a successful keypress occurs while focused on a component focus Component gains keyboard focus blur Component loses keyboard focus Table 5–3 Cont. ADF Faces Client Events Event Type Event Class Propagates to Server Can Be Canceled Triggered by Component