Skip Headers
Oracle® Application Development Framework Developer's Guide
10g Release 3 (10.1.3)
B25386-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

11.3 Using Popup Dialogs

Sometimes you might want to display a new page in a separate popup dialog instead of displaying it in the same window containing the current page. In the popup dialog, you might let the user enter or select information, and then return to the original page to use that information. Ordinarily, you would need to use JavaScript to launch the popup dialog and manage the process, and create code for managing cases where popup dialogs are not supported on certain client devices such as a PDA. With the dialog framework, ADF Faces has made it easy to launch and manage popup dialogs and processes without using JavaScript.

Consider a simple application that requires users to log in to see their orders. Figure 11-3 shows the page flow for the application, which consists of five pages—login.jspx, orders.jspx, new_account.jspx, account_details.jspx, and error.jspx.

Figure 11-3 Page Flow of a Dialog Sample Application

Navigation diagram showing five pages.

When an existing user logs in successfully, the application displays the Orders page, which shows the user's orders, if there are any. When a user does not log in successfully, the Error page displays in a popup dialog, as shown in Figure 11-4.

Figure 11-4 Error Page in a Popup Dialog

Error message in a popup dialog

On the Error page there is a Cancel button. When the user clicks Cancel, the popup dialog closes and the application returns to the Login page, as shown in Figure 11-5.

Figure 11-5 Login Page

Login screen for username and password

When a new user clicks the New User link on the Login page, the New Account page displays in a popup dialog, as shown in Figure 11-6.

Figure 11-6 New Account Page in a Popup Dialog

New Account screen asking for name and address

After entering information such as first name and last name, the user then clicks the Details button to display the Account Details page in the same popup dialog, as shown in Figure 11-7. In the Account Details page, the user enters other information and confirms a password for the new login account. There are two buttons on the Account Details page—Cancel and Done.

Figure 11-7 Account Details Page in a Popup Dialog

Account Details screen to confirm country and password

If the new user decides not to proceed with creating a new login account and clicks Cancel, the popup dialog closes and the application returns to the Login page. If the new user clicks Done, the popup dialog closes and the application returns to the Login page where the Username field is now populated with the user's first name, as shown in Figure 11-8. The new user can then proceed to enter the new password and log in successfully.

Figure 11-8 Login Page With the Username Field Populated

Login screen with username field populated

11.3.1 How to Create Popup Dialogs

To make it easy to support popup dialogs in your application, ADF Faces has built in the dialog functionality to components that implement ActionSource (such as commandButton and commandLink). For ADF Faces to know whether to launch a page in a popup dialog from an ActionSource component, four conditions must exist:

  • There must be a JSF navigation rule with an outcome that begins with "dialog:".

  • The command component's action outcome must begin with "dialog:".

  • The useWindow attribute on the command component must be "true".

  • The client device must support popup dialogs.


Note:

If useWindow is false or if the client device doesn't support popup dialogs, ADF Faces automatically shows the page in the current window instead of using a popup—code changes are not needed to facilitate this.

The page that displays in a popup dialog is an ordinary JSF page. But for purposes of explaining how to implement popup dialogs in this chapter, a page that displays in a popup dialog is called the dialog page, and a page from which the popup dialog is launched is called the originating page. A dialog process starts when the originating page launches a dialog (which can contain one dialog page or a series of dialog pages), and ends when the user dismisses the dialog and is returned to the originating page.

The tasks for supporting popup dialogs in an application are:

  1. Define a JSF navigation rule for launching a dialog.

  2. Create the JSF page from which a dialog is launched.

  3. Create the dialog page and return a dialog value.

  4. Handle the return value.

  5. Pass a value into a dialog.

The tasks can be performed in any order.

11.3.1.1 Defining a JSF Navigation Rule for Launching a Dialog

You manage the navigation into a popup dialog by defining a standard JSF navigation rule with a special dialog: outcome. Using the dialog sample application shown in Figure 11-3, three navigation outcomes are possible from the Login page:

  • Show the Orders page in the same window (successful login)

  • Show the Error dialog page in a popup dialog (login failure)

  • Show the New Account dialog page in a popup dialog (new user)

Example 11-16 shows the navigation rule for the three navigation cases from the Login page (login.jspx).

Example 11-16 Dialog Navigation Rules in the faces-config.xml File

<navigation-rule>

  <!-- Originating JSF page -->
  <from-view-id>/login.jspx</from-view-id>

  <!-- Navigation case for the New Account dialog page (new user)-->
  <navigation-case>
    <from-outcome>dialog:newAccount</from-outcome>
    <to-view-id>/new_account.jspx</to-view-id>
  </navigation-case>

  <!-- Navigation case for the Error dialog page (upon login failure) -->
  </navigation-case>
    <from-outcome>dialog:error</from-outcome>
    <to-view-id>/error.jspx</to-view-id>
  </navigation-case>

  <!-- Navigation case for the Orders page (upon login success) -->
  </navigation-case>
    <from-outcome>orders</from-outcome>
    <to-view-id>/orders.jspx</to-view-id>
  </navigation-case>

</navigation-rule>

11.3.1.1.1 What Happens at Runtime

The dialog navigation rules on their own simply show the specified pages in the main window. But when used with command components with dialog: action outcomes and with useWindow attributes set to true, ADF Faces knows to launch the pages in popup dialogs. This is described in the next step.

11.3.1.2 Creating the JSF Page That Launches a Dialog

In the originating page from which a popup dialog is launched, you can use either an action method or a static action outcome on the ActionSource component. Whether you specify a static action outcome or use an action method that returns an action outcome, this action outcome must begin with dialog:.

The sample application uses an action method binding on the commandButton component to determine programmatically whether to navigate to the Orders page or the Error dialog page, and a static action outcome on the commandLink component to navigate directly to the New Account dialog page. Both command components are on the Login page. Example 11-17 shows the code for the Login commandButton component.

Example 11-17 Login Button on the Login Page

af:commandButton id="cmdBtn"
                 text="Login"
                 action="#{backing_login.commandButton_action}"
                 useWindow="true"
                 windowHeight="200"
                 windowWidth="500"
                 partialSubmit="true"/>

The attributes useWindow, windowHeight, and windowWidth are used in launching pages in popup dialogs. These attributes are ignored if the client device doesn't support popup dialogs.

When useWindow="true" ADF Faces knows to launch the dialog page in a new popup dialog. The windowHeight and windowWidth attributes specify the size of the popup dialog.


Tip:

Set the partialSubmit attribute on the commandButton component to true. This prevents the originating page from refreshing (and hence flashing momentarily) when the popup dialog displays.

The action attribute on commandButton specifies a reference to an action method in the page's backing bean, Login.java. The action method must return an outcome string, which JSF uses to determine the next page to display by comparing the outcome string to the outcomes in the navigation cases defined in faces-config.xml. The code for this action method is shown in Example 11-18.

Example 11-18 Action Method Code for the Login Button

public String commandButton_action()
{
  String retValue;
  retValue = "orders";
  _cust = getListCustomer();
  if (_cust == null || !password.equals(_cust.getPassword()))
  {
    retValue = "dialog:error";
  }
  
  return retValue;
}

Example 11-19 shows the code for the New User commandLink component that uses a static action outcome.

Example 11-19 New User Command Link on the Login Page

<af:commandLink id="cmdLink" 
                text="New User?"
                action="dialog:newAccount"
                useWindow="true"
                partialSubmit="true"
                windowHeight="200"
                windowWidth="500" />

Instead of referencing an action method, the action attribute value is simply a static outcome string that begins with dialog:.

11.3.1.2.1 What Happens at Runtime

ADF Faces uses the attribute useWindow="true" in conjunction with an action outcome that begins with dialog: to determine whether to start a dialog process and launch a page in a popup dialog (assuming dialog: navigation rules have been defined in faces-config.xml).

If the action outcome does not begin with dialog:, ADF Faces does not start a process or launch a popup dialog even when useWindow="true". Conversely, if the action outcome begins with dialog:, ADF Faces does not launch a popup dialog if useWindow="false" or if useWindow is not set, but ADF Faces does start a new process.

If the client device does not support popup dialogs, ADF Faces shows the dialog page in the current window after preserving all the state of the current page—you don't have to write any code to facilitate this.

When a command component is about to launch a dialog, it delivers a launch event (LaunchEvent). The launch event stores information about the component that is responsible for launching a popup dialog, and the root of the component tree to display when the dialog process starts. A launch event can also pass a map of parameters into the dialog. For more information, see Section 11.3.1.5, "Passing a Value into a Dialog".

11.3.1.3 Creating the Dialog Page and Returning a Dialog Value

The dialog pages in our sample application are the Error page, the New Account page, and the Account Details page. The dialog process for a new user actually contains two pages: the New Account page and the Account Details page. The dialog process for a user login failure contains just the Error page.

A dialog page is just like any other JSF page, with one exception. In a dialog page you must provide a way to tell ADF Faces when the dialog process finishes, that is, when the user dismisses the dialog. Generally, you do this programmatically or declaratively via a command component. Example 11-20 shows how to accomplish this programmatically via a Cancel button on the Error page.

Example 11-20 Cancel Button on the Error Page

<af:commandButton text="Cancel"
                  actionListener="#{backing_error.cancel}" />

The actionListener attribute on commandButton specifies a reference to an action listener method in the page's backing bean, Error.java. The action listener method processes the action event that is generated when the Cancel button is clicked. You call the AdfFacesContext.returnFromDialog() method in this action listener method, as shown in Example 11-21.

Example 11-21 Action Listener Method for the Cancel Button in a Backing Bean

public void cancel(ActionEvent actionEvent)
{
  AdfFacesContext.getCurrentInstance().returnFromDialog(null, null);
}


Note:

The AdfFacesContext.returnFromDialog() method returns null. This is all that is needed in the backing bean to handle the Cancel action event.

To accomplish the same declaratively on the Account Details dialog page, attach a af:returnActionListener tag to the Cancel button component, as shown in Example 11-22. The af:returnActionListener tag calls the returnFromDialog method on the AdfFacesContext—no backing bean code is needed.

Example 11-22 Cancel Button on the Account Details Page

<af_commandButton text="Cancel" immediate="true">
  <af:returnActionListener/>
</af:commandButton>

No attributes are used with the af:returnActionListener tag. The immediate attribute on commandButton is set to true: if the user clicks Cancel without entering values in the required Password and Confirm Password fields, the default JSF ActionListener can execute during the Apply Request Values phase instead of the Invoke Application phase, thus bypassing input validation.

The New Account page and Account Details page belong in the same dialog process. A dialog process can have as many pages as you desire, but you only need to call AdfFacesContext.returnFromDialog() once.

The same af:returnActionListener tag or AdfFacesContext.returnFromDialog() method can also be used to end a process and return a value from the dialog. For example, when the user clicks Done on the Account Details page, the process ends and returns the user input values. Example 11-23 shows the code for the Done button.

Example 11-23 Done Button on the Account Details Page

<af:commandButton text="Done"
                  actionListener="#{backing_new_account.done}" />

The actionListener attribute on commandButton specifies a reference to an action listener method in the page's backing bean, New_account.java. The action listener method processes the action event that is generated when the Done button is clicked. Example 11-24 shows the code for the action listener method, where the return value is retrieved, and then returned via the AdfFacesContext.returnFromDialog() method.

Example 11-24 Action Listener Method for the Done Button in a Backing Bean

public void done(ActionEvent e)
{

  AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();

  String firstname = afContext.getProcessScope().get("firstname").toString();
  String lastname = afContext.getProcessScope().get("lastname").toString();
  String street = afContext.getProcessScope().get("street").toString();
  String zipCode = afContext.getProcessScope().get("zipCode").toString();
  String country = afContext.getProcessScope().get("country").toString();
  String password = afContext.getProcessScope().get("password").toString();
  String confirmPassword =
   afContext.getProcessScope().get("confirmPassword").toString();

  if (!password.equals(confirmPassword))
  {
    FacesMessage fm = new FacesMessage();
    fm.setSummary("Confirm Password");
    fm.setDetail("You've entered an incorrect password. Please verify that you've
     entered a correct password!");
    FacesContext.getCurrentInstance().addMessage(null, fm);
  }
  else
  {
    //Get the return value 
    Customer cst = new Customer();
    cst.setFirstName(firstname);
    cst.setLastName(lastname);
    cst.setStreet(street);
    cst.setPostalCode(zipCode);
    cst.setCountry(country);
    cst.setPassword(password);

    // And return it
    afContext.getCurrentInstance().returnFromDialog(cst, null);
    afContext.getProcessScope().clear();
  }
}

The AdfFacesContext.returnFromDialog() method lets you send back a return value in the form of a java.lang.Object or a java.util.Map of parameters. You don't have to know where you're returning the value to—ADF Faces automatically takes care of it.

11.3.1.3.1 What Happens at Runtime

The AdfFacesContext.returnFromDialog() method tells ADF Faces when the user dismisses the dialog. This method can be called whether the dialog page is shown in a popup dialog or in the main window. If a popup dialog is used, ADF Faces automatically closes it.

In the sample application, when the user clicks the Cancel button on the Error page or Account Details page, ADF Faces calls AdfFacesContext.returnFromDialog(), (which returns null), closes the popup dialog, and returns to the originating page.

The first page in the new user dialog process is the New Account page. When the Details button on the New Account page is clicked, the application shows the Account Details dialog page in the same popup dialog (because useWindow="false"), after preserving the state of the New Account page.

When the Done button on the Account Details page is clicked, ADF Faces closes the popup dialog and AdfFacesContext.returnFromDialog() returns cst to the originating page.

When the dialog is dismissed, ADF Faces generates a return event (ReturnEvent). The AdfFacesContext.returnFromDialog() method sends a return value as a property of the return event. The return event is delivered to the return listener (ReturnListener) that is registered on the command component that launched the dialog (which would be the New User commandLink on the Login page). How you would handle the return value is described in Section 11.3.1.4, "Handling the Return Value".

11.3.1.4 Handling the Return Value

To handle a return value, you register a return listener on the command component that launched the dialog, which would be the New User link component on the Login page in the sample application. Example 11-25 shows the code for the New User link component.

Example 11-25 New User Command Link on the Login Page

<af:commandLink id="cmdLink" text="New User?"
                action="dialog:newAccount"
                useWindow="true"
                returnListener="#{backing_login.handleReturn}"
                partialSubmit="true"
                windowHeight="200"
                windowWidth="500" />

The returnListener attribute on commandLink specifies a reference to a return listener method in the page's backing bean, Login.java. The return listener method processes the return event that is generated when the dialog is dismissed. Example 11-26 shows the code for the return listener method that handles the return value.

Example 11-26 Return Listener Method for the New User Link in a Backing Bean

public void handleReturn(ReturnEvent event)
{
  if (event.getReturnValue() != null)
  {

    Customer cst;
    String name;
    String psw;

    cst = (Customer)event.getReturnValue();
    name = cst.getFirstName();
    psw = cst.getPassword();
    CustomerList.getCustomers().add(cst);

    inputText1.setSubmittedValue(null);
    inputText1.setValue(name);
    inputText2.setSubmittedValue(null);
    inputText2.setValue(psw);

  }
}

You use the getReturnValue() method to retrieve the return value, because the return value is automatically added as a property of the ReturnEvent.

11.3.1.4.1 What Happens at Runtime

In the sample application, when ADF Faces delivers a return event to the return listener registered on the commandLink component, the handleReturn() method is called and the return value is processed accordingly. The new user is added to a customer list, and as a convenience to the user any previously submitted values in the Login page are cleared and the input fields are populated with the new information.

11.3.1.5 Passing a Value into a Dialog

The AdfFacesContext.returnFromDialog() method lets you send a return value back from a dialog. Sometimes you might want to pass a value into a dialog. To pass a value into a dialog, you use a launch listener (LaunchListener).

In the sample application, a new user can enter a name in the Username field on the Login page, and then click the New User link. When the New Account dialog page displays in a popup dialog, the First Name input field is automatically populated with the name that was entered in the Login page. To accomplish this, you register a launch listener on the command component that launched the dialog (which would be commandLink). Example 11-27 shows the code for the commandLink component.

Example 11-27 Input Field and New User Command Link on the Login Page

<af:inputText label="Username"
              value="#{backing_login.username}"/>

<af:commandLink id="cmdLink" text="New User?"
                action="dialog:newAccount"
                useWindow="true"
                launchListener="#{backing_login.handleLaunch}"
                returnListener="#{backing_login.handleReturn}"
                partialSubmit="true"
                windowHeight="200"
                windowWidth="500" />

The LaunchListener attribute on commandLink specifies a reference to a launch listener method in the page's backing bean, Login.java. In the launch listener method you use the getDialogParameters() method to add a parameter to a Map using a key-value pair. Example 11-28 shows the code for the launch listener method.

Example 11-28 Launch Listener Method for the New User Command Link in a Backing Bean

public void handleLaunch(LaunchEvent event)
{
  //Pass the current value of the field into the dialog
  Object usr = username;
  event.getDialogParameters().put("firstname", usr);
}

...
// Use by inputText value binding 

public String username;
public String getUsername()
{
  return username;
}

public void setUsername(String username)
{
  this.username = username;
}
...

To show the parameter value in the New Account dialog page, use the ADF Faces processScope to retrieve the key and value via a special EL expression in the format #{processScope.someKey}, as shown in Example 11-29.

Example 11-29 Input Field on the New Account Page

<af:inputText label="First name"
              value="#{processScope.firstname}"/>


Note:

You can use processScope with all JSF components, not only with ADF Faces components.

11.3.1.5.1 What Happens at Runtime

When a command component is about to launch a dialog (assuming all conditions have been met), ADF Faces queues a launch event. This event stores information about the component that is responsible for launching a dialog, and the root of the component tree to display when the dialog process starts. Associated with a launch event is a launch listener, which takes the launch event as a single argument and processes the event as needed.

In the sample application, when ADF Faces delivers the launch event to the launch listener registered on the commandLink component, the handleLaunch() method is called and the event processed accordingly.

In ADF Faces, a process always gets a copy of all the values that are in the processScope of the page from which a dialog is launched. When the getDialogParameters() method has added parameters to a Map, those parameters also become available in processScope, and any page in the dialog process can get the values out of processScope by referring to the processScope objects via EL expressions.

Unlike sessionScope, processScope values are visible only in the current "page flow" or process. If the user opens a new window and starts navigating, that series of windows has its own process; values stored in each window remain independent. Clicking on the browser's Back button automatically resets processScope to its original state. When you return from a process the processScope is back to the way it was before the process started. To pass values out of a process you would use AdfFacesContext.returnFromDialog(), sessionScope or applicationScope.

11.3.2 How the SRDemo Popup Dialogs Are Created

The SRDemo application uses a popup dialog to:

  • Display a list of frequently asked questions (FAQ).

  • Select and assign a technician to an open service request.

In the Create New Service Request page (see Figure 11-13), when the user clicks the Frequently Asked Questions link, the application displays a popup dialog showing the FAQ list.

In the Edit Service Request page, when the user clicks the flashlight icon next to the Assigned to label (see Figure 11-12), the application displays the Search for Staff popup dialog. In the dialog (as shown in Figure 11-9), the user makes a search based on user role, then clicks the radio button next to a name and clicks Select.

Figure 11-9 Search for Staff Popup Dialog (SRStaffSearch.jspx)

Search form to search staff by role

After making a selection, the popup dialog closes and the application returns to the Edit Service Request page where the Assigned to display-only fields are now updated with the selected technician's first name and last name, as shown in Figure 11-10.

Figure 11-10 Edit Service Request Page (SREdit.jspx) With an Assigned Request

Edit Service Request page showing assigned request

To reiterate, the tasks for supporting a popup dialog are (not listed in any particular order):

  1. Create the JSF navigation rules with dialog: outcomes.

  2. Create the page that launches the dialog via a dialog: action outcome.

  3. Create the dialog page and return a value.

  4. Handle the return value.

Firstly, the JSF navigation rules for launching dialogs are shown in Example 11-30. The navigation case for showing the dialog page SRStaffSearch.jspx is defined by the dialog:StaffSearch outcome; the navigation case for showing the SRFaq.jspx dialog page is defined by the dialog:FAQ outcome.

Example 11-30 Dialog Navigation Rules in the faces-config.xml File

<navigation-rule>
  <from-view-id>/SREdit.jspx</from-view-id>
  ...
  <navigation-case>
    <from-outcome>dialog:StaffSearch</from-outcome>
    <to-view-id>/SRStaffSearch.jspx</to-view-id>
  </navigation-case>
</navigation-rule>
<navigation-rule>
  <from-view-id>/SRCreate.jspx</from-view-id>
  <navigation-case>
    <from-outcome>dialog:FAQ</from-outcome>
    <to-view-id>/SRFaq.jspx</to-view-id>
  </navigation-case>
  ...
</navigation-rule>

Secondly, the pages that launch popup dialogs are SREdit.jspx and SRCreate.jspx. In both pages the useWindow attribute on the commandLink component is set to true, which is a precondition for ADF Faces to know that it has to launch a popup dialog.

Example 11-31 shows the commandLink component on the page that launches the SRStaffSearch.jspx dialog page. The commandLink component has the static action outcome dialog:StaffSearch.

Example 11-31 CommandLink Component for Launching the SRStaffSearch Dialog Page

<af:commandLink id="staffLOVLink" action="dialog:StaffSearch"
                useWindow="true" immediate="true"
                partialSubmit="true"
                returnListener="#{backing_SREdit.handleStaffLOVReturn}"..>
  <af:objectImage height="24" width="24"
                  source="/images/searchicon_enabled.gif"/>
</af:commandLink>

Example 11-32 shows the commandLink component on the page that launches the SRFaq.jspx dialog page. The commandLink component has the static action outcome dialog:SRFaq.

Example 11-32 CommandLink Component for Launching the SRFaq Dialog Page

<af:commandLink action="dialog:FAQ" 
                text="#{res['srcreate.faqLink']}"
                useWindow="true"
                immediate="true"
                partialSubmit="true"/>

Thirdly, the dialog pages SRStaffSearch.jspx and SRFaq.jspx have to call the AdfFacesContext.returnFromDialog() method to let ADF Faces know when the user dismisses the dialogs. In SRStaffSearch.jspx, which uses a table component with a tableSelectOne component to display the names for selection, the AdfFacesContext.returnFromDialog() method is called when the user clicks the radio button for a technician in the table and then clicks the Select commandButton. The action attribute on commandButton is bound to the selectStaff_action action method in the page's backing bean (SRStaffSearch.java); the action method retrieves the selected row data from the table and then returns it via the AdfFacesContext.returnFromDialog() method. Example 11-33 shows the code snippets for the Select commandButton and its selectStaff_action action method.

Example 11-33 Action Method for the Select Command Button

<af:tableSelectOne>
  <af:commandButton text="#{res['srstaffsearch.button.select']}"
                    action="#{backing_SRStaffSearch.selectButton_action}"/>
</af:tableSelectOne>

...
...
public String selectButton_action() {
        
  //get row data from table
  JUCtrlValueBindingRef selectedRowData = (JUCtrlValueBindingRef)
   this.getResultsTable().getSelectedRowData();
  RowImpl row = (RowImpl)selectedRowData.getRow();
  User staffMember = (User)row.getDataProvider();
                
  // And return it
  AdfFacesContext.getCurrentInstance().returnFromDialog(staffMember, null);
  // no navigation to another page and thus null is returned
  return null;
}

Similarly in SRFaq.jspx, a commandLink component is used to close and call the AdfFacesContext.returnFromDialog() method. The af:returnActionListener tag calls the returnFromDialog method on the AdfFacesContext—no backing bean code is needed. Example 11-34 shows the code snippet for the commandLink. When the user dismisses the SRFaq.jspx popup dialog, ADF Faces simply closes the dialog. No dialog return value is sent, so there's no need to handle a return value.

Example 11-34 CommandLink Component for Closing the SRFaq Popup Dialog

<af:commandLink text="#{res['srdemo.close']}">
  <af:returnActionListener/>
</af:commandLink>

When the SRStaffSearch.jspx popup dialog is dismissed, a dialog return value (that is, the selected row data) is sent as a property of the return event (ReturnEvent). The return event is delivered to the return listener registered on the commandLink component of the originating page SREdit.jspx, as shown in Example 11-35. The returnListener attribute on commandLink is bound to the handleStaffLOVReturn listener method in the page's backing bean (SREdit.java). The return listener method handles the return value from the dismissed dialog. Example 11-35 also shows the code snippet for the handleStaffLOVReturn listener method.

Example 11-35 Return Listener Method for Handling the Return Value

<af:commandLink id="staffLOVLink" action="dialog:StaffSearch"
                useWindow="true" immediate="true"
                partialSubmit="true"
                returnListener="#{backing_SREdit.handleStaffLOVReturn}"..>
  <af:objectImage height="24" width="24"
                  source="/images/searchicon_enabled.gif"/>
</af:commandLink>
...
...
  public void handleStaffLOVReturn(ReturnEvent event) {
    //Get the return value from the pop up
    User returnedStaffMember = (User)event.getReturnValue();
 
    if (returnedStaffMember != null) {
      DCBindingContainer bc = (DCBindingContainer)getBindings();

      // Get the handle to the Service Request we are editing
      DCControlBinding thisSRId = 
        (DCControlBinding)bc.getControlBinding("svrId");
      RowImpl srRowImpl = (RowImpl)thisSRId.getCurrentRow();
      ServiceRequest thisSR = (ServiceRequest)srRowImpl.getDataProvider();
 
      //See if a different user has been selected? 
      User oldUser = thisSR.getAssignedTo();
      if ((oldUser == null) || (!oldUser.equals(returnedStaffMember))) {

        //Set the returned Staff member from the LOV
        thisSR.setAssignedTo(returnedStaffMember);
 
        //now re-execute the iterator to refresh the screen
        DCControlBinding accessorData = 
          (DCControlBinding)bc.getControlBinding("assignedToFirstName");
        accessorData.getDCIteratorBinding().executeQuery();
 
        //Now reset the Assigned date
        ADFUtils.setPageBoundAttributeValue(getBindings(), "assignedDate", 
                                     new Timestamp(System.currentTimeMillis()));
 
        //And get the data field to update with the new bound value
               this.getAssignedDate().resetValue();                                                                                     
 
      }
    }
  }

11.3.3 What You May Need to Know About ADF Faces Dialogs

The ADF Faces dialog framework has these known limitations:

  • Does not support the use of </redirect> in navigation rules that may launch dialog pages in new popup dialogs. You can, however, use </redirect> in navigation rules that launch dialog pages within the same window.

  • Cannot detect popup blockers. If you use popup dialogs in your web application, tell your users to disable popup blocking for your site.

11.3.4 Other Information

The ADF Faces select input components (such as selectInputText and selectInputDate) also have built-in dialog support. These components automatically handle launching a page in a popup dialog, and receiving the return event. For example, when you use selectInputText to launch a dialog, all you have to do is to set the action attribute to a dialog: outcome, and specify the width and height of the dialog. When the user dismisses the dialog, the return value from the dialog is automatically used as the new value of the input component. You would still need to define a JSF navigation rule with the dialog: outcome, create the dialog page, and create the dialog page's backing bean to handle the action events.

Besides being able to launch popup dialogs from action events, you can also launch popup dialogs from value change events and poll events. For example, you can programmatically launch a dialog (without a JSF navigation rule) by using the AdfFacesContext.launchDialog() method in a value change listener method or poll listener method.

If you're a framework or component developer you can enable a custom renderer to launch a dialog and handle a return value, or add LaunchEvent and ReturnEvent events support to your custom ActionSource components. For details about the DialogService API that you can use to implement dialogs, see the ADF Faces Javadoc for oracle.adf.view.faces.context.DialogService. See also the ADF Faces Developer's Guide for further information about supporting dialogs in custom components and renderers.