How to Create a Note Window

13-14 Web User Interface Developers Guide for Oracle Application Development Framework Using the variable source, you can take values from the source and apply them, or you can set values. For example, you could get the full name value of the people object used in the table, and set it as the value of the testBean’s fullName property used by the window, using a setPropertyListener and clientAttribute tag, as shown in Example 13–5 . Example 13–5 Setting the Value of a Component in a Popup Using the launcherVar Property af:popup id=noteWindow contentDelivery=lazyUncached eventContext=launcher launcherVar=source af:noteWindow af:outputText value={testBean.fullName} af:noteWindow af:setPropertyListener from={source.attributes.fullName} to={testBean.fullName} type=popupFetch af:popup af:table var=person value={testBean.people} af:column id=firstName f:facet name=header af:outputText value=First Name f:facet af:commandLink text={person.firstName} af:showPopupBehavior popupId=::noteWindow triggerType=mouseHover af:clientAttribute name=fullName value={person.fullName} af:commandLink af:column af:table In this example, the launcherVar property source gets the full name for the current row using the popupFetch event. For more information about using the setPropertyListener tag, see Section 4.7.2, How to Use the pageFlowScope Scope Without Writing Java Code. For more information about using client attributes, see Section 3.7, Using Bonus Attributes for Client-Side Components. For more information about the showPopupBehavior tag, see Section 13.4, Invoking Popup Elements. Popups also invoke the following client-side events: ■ popupOpening: Fired when the popup is invoked. If this event is canceled in a client-side listener, the popup will not be shown. ■ popupOpened: Fired after the popup becomes visible. One example for using this event would be to create custom rules for overriding default focus within the popup. ■ popupCanceled: Fired when a popup is unexpectedly dismissed by auto-dismissal or by explicitly invoking the popup client components cancel method. This client-side event also has a server-side counterpart. ■ popupClosed: Fired when the popup is hidden or when the popup is unexpectedly dismissed. This client-side event also has a server-side counterpart. When a popup is closed by an affirmative condition, for example, when the Yes button is clicked, it is hidden. When a popup is closed by auto-dismissal, for example when either the Close icon or the Cancel button is clicked, it is canceled. Both types of dismissals result in raising a popupClosed client-side event. Canceling a popup also raises a client-side popupCanceled event that has an associated server-side counterpart. The event will not be propagated to the server unless there are registered listeners for the event. If it is propagated, it prevents processing of any child Using Popup Dialogs, Menus, and Windows 13-15 components to the popup, meaning any submitted values and validation are ignored. You can create a listener for the popupCanceled event that contains logic to handle any processing needed when the popup is canceled. If you want to invoke some logic based on a client-side event, you can create a custom client listener method. For more information, see Section 3.2, Listening for Client Events. If you want to invoke server-side logic based on a client event, you can add a serverListener tag that will invoke that logic. For more information, see Section 5.4, Sending Custom Events from the Client to the Server.

13.3 Programmatically Invoking a Popup

You can programmatically show, hide, or cancel a popup in response to an actionEvent generated by a command component. Implement this functionality if you want to deliver the actionEvent to the server immediately so you can invoke server-side logic and show, hide, or cancel the popup in response to the outcome of invoking the server-side logic. Programmatically invoking a popup as described here differs to the method of invoking a popup described in Section 13.2, Declaratively Creating Popup Elements where the showPopupBehavior tag does not deliver the actionEvent to the server immediately. You create the type of popup that you want by placing one of the components dialog, panelWindow, menu, or noteWindow inside the popup component as described in Section 13.2, Declaratively Creating Popup Elements. Make sure that the popup component is in the right context when you invoke it. One of the easier ways to do this is to bind it to the backing bean for the page, as in Example 13–6 . Example 13–6 Binding a popup Component to a Backing Bean af:popup id=p1 binding={mybean.popup} ... Once you have done this, you configure a command components actionListener attribute to reference the popup component by calling an accessor for the popup binding. Write code for the backing bean method that invokes, cancels, or hides the popup. Example 13–7 shows a showPopup backing bean method that uses the HINT_ LAUNCH_ID hint to identify the command component that passes the actionEvent to it and p1 to reference the popup on which we invoke the show method. Example 13–7 Backing Bean Method Invoking a Popup public void showPopupActionEvent event { { FacesContext context = FacesContext.getCurrentInstance; UIComponent source = UIComponentevent.getSource; String alignId = source.getClientIdcontext; RichPopup.PopupHints hints = new RichPopup.PopupHints; hints.addRichPopup.PopupHints.HintTypes.HINT_ALIGN_ID,source .addRichPopup.PopupHints.HintTypes.HINT_LAUNCH_ID,source .addRichPopup.PopupHints.HintTypes.HINT_ALIGN, RichPopup.PopupHints.AlignTypes.ALIGN_AFTER_END; p1.showhints; } 13-16 Web User Interface Developers Guide for Oracle Application Development Framework Example 13–8 shows a backing bean method that cancels a popup in response to an actionEvent: Example 13–8 Backing Bean Method Canceling a Popup public void cancelPopupActionListenerActionEvent event { FacesContext context = FacesContext.getCurrentInstance; p1.cancel; } Example 13–9 shows a backing bean method that hides a popup in response to an actionEvent: Example 13–9 Backing Bean Method Hiding a Popup public void hidePopupActionListenerActionEvent event { FacesContext context = FacesContext.getCurrentInstance; p1.hide; } The p1 object in the previous examples refers to an instance of the RichPopup class from the following package: oracle.adf.view.rich.component.rich.RichPopup For more information about RichPopup, see the Oracle Fusion Middleware Java API Reference for Oracle ADF Faces.

13.3.1 How to Programatically Invoke a Popup

You configure the command component’s actionListener attribute to reference the backing bean method that shows, cancels or hides the popup. Before you begin: Create the type of popup that you want the server-side method to invoke, as described in Section 13.2, Declaratively Creating Popup Elements. It may be helpful to have an understanding of the configuration options available to you if you want to invoke a popup component programmatically. For more information, see Section 13.3, Programmatically Invoking a Popup. To programmatically invoke a popup: 1. In the Component Palette, from the General Controls panel, drag and drop a command component onto the JSF page. For example, a Button component. 2. In the Property Inspector, expand the Behavior section and set the following attributes: ■ PartialSubmit : set to true if you do not want the Fusion web application to render the entire page after an end user clicks the command component. The default value false causes the application to render the whole page after an end user invokes the command component. For more information about page rendering, see Chapter 7, Rerendering Partial Page Content. ■ ActionListener : set to an EL expression that evaluates to a backing bean method with the logic that you want to execute when the end user invokes the command component at runtime.