Events and Partial Page Rendering

5-4 Web User Interface Developers Guide for Oracle Application Development Framework This focus event is generated when focusing in on a specific subtree, which is not the same as a client-side keyboard focus event. The LoadEvent event is fired after the initial page is displayed data streaming results may arrive later. All server events have event listeners on the associated components. You need to create a handler that processes the event and then associate that handler code with the listener on the component. For example, in the File Explorer application, a selection event is fired when a user selects a row in the table. Because the table’s selectionListener attribute is bound to the tableSelectFileItem handler method on the TableContentView.java managed bean, that method is invoked in response to the event. To handle server-side events: 1. In a managed bean or the backing bean for the page that will use the event listener, create a public method that accepts the event as the event type as the only parameter and returns void. Example 5–1 shows the code for the tableSelectFileItem handler. For information about creating and using managed beans, see Section 2.6, Creating and Using Managed Beans. Example 5–1 Event Listener Method public void tableSelectFileItemSelectionEvent selectionEvent { FileItem data = FileItemthis.getContentTable.getSelectedRowData; Table 5–2 ADF Faces Server Events Event Triggered by Component... ActionEvent All command components DialogEvent dialog DisclosureEvent showDetail, showDetailHeader, showDetailItem FocusEvent tree, treeTable LaunchEvent All command components LaunchPopupEvent inputListOfValues, inputComboboxListOfValues LoadEvent document PollEvent poll QueryEvent query, quickQuery QueryOperationEvent query, quickQuery RangeChangeEvent table RegionNavigationEvent region ReturnEvent All command components ReturnPopupEvent inputListOfValues, inputComboboxListOfValues RowDisclosureEvent tree, treeTable SelectionEvent tree, treeTable, table SortEvent treeTable, table ValueChangeEvent All input and select components components that implement EditableValueHolder 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 }