How to Use the pageFlowScope Scope Within Java Code

5 Handling Events 5-1 5 Handling Events This chapter describes how to handle events on the server as well as on the client. This chapter includes the following sections: ■ Section 5.1, Introduction to Events and Event Handling ■ Section 5.2, Using ADF Faces Server Events ■ Section 5.3, Using JavaScript for ADF Faces Client Events ■ Section 5.4, Sending Custom Events from the Client to the Server ■ Section 5.5, Executing a Script Within an Event Response ■ Section 5.6, Using Client Behavior Tags ■ Section 5.7, Using Polling Events to Update Pages

5.1 Introduction to Events and Event Handling

In traditional JSF applications, event handling typically takes place on the server. JSF event handling is based on the JavaBeans event model, where event classes and event listener interfaces are used by the JSF application to handle events generated by components. Examples of user events in an application include clicking a button or link, selecting an item from a menu or list, and changing a value in an input field. When a user activity occurs such as clicking a button, the component creates an event object that stores information about the event and identifies the component that generated the event. The event is also added to an event queue. At the appropriate time in the JSF lifecycle, JSF tells the component to broadcast the event to the appropriate registered listener, which invokes the listener method that processes the event. The listener method may trigger a change in the user interface, invoke backend application code, or both. Like standard JSF components, ADF Faces command components deliver ActionEvent events when the components are activated, and ADF Faces input and select components deliver ValueChangeEvent events when the component local values change. For example, in the File Explorer application, the File Menu contains a submenu whose commandMenuItem components allow a user to create a new file or folder. When users click the Folder commandMenuItem, an ActionEvent is invoked. Because the EL expression set as the value for the component’s actionListener attribute resolves to the createNewDirectory method on the headerManager managed bean, that method is invoked and a new directory is created. 5-2 Web User Interface Developers Guide for Oracle Application Development Framework While ADF Faces adheres to standard JSF event handling techniques, it also enhances event handling in two key ways by providing: ■ Ajax-based functionality partial page rendering ■ A client-side event model

5.1.1 Events and Partial Page Rendering

Unlike standard JSF events, ADF Faces events support AJAX-style partial postbacks to enable partial page rendering PPR. Instead of full page rendering, ADF Faces events and components can trigger partial page rendering, that is, only portions of a page refresh upon request. Certain components are considered event root components. Event root components determine boundaries on the page, and so allow the lifecycle to run just on components within that boundary for more information about this aspect of the lifecycle, see Section 4.3, Using the Optimized Lifecycle . When an event occurs within an event root, only those components that are children to the root are refreshed on the page. An example of an event root component is a popup. When an event happens within a popup, only the popup and its children are rerendered, and not the whole page. Additionally, certain events indicate a specific component as an event root component. For example, the disclosure event sent when a expanding or collapsing a showDetail component see Section 8.8, Displaying and Hiding Contents Dynamically , indicates that the showDetail component is a root. The lifecycle is run only on the showDetail component and any child components or other components that point to this as a trigger, and only they are rerendered when it is expanded or collapsed. Table 5–1 shows the event types in ADF Faces, and whether or not the source component is an event root. Note: Any ADF Faces component that has built-in event functionality must be enclosed in the form tag. Table 5–1 Events and Event Root Components Event Type Component Trigger Is Event Root action All command components false dialog dialog false disclosure showDetail, showDetailHeader true disclosure showDetailItem true focus tree, treeTable true launch All command components NA launchPopup inputListOfValues, inputComboboxListOfValues true load document NA poll poll true popupOpened popup NA popupOpening popup NA popupClosed popup NA