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
 

9.3 Creating Simple Navigation Using Static Outcome Values

The simplest form of page navigation uses static navigation. Static navigation involves simply moving from one page to another based on a single, static outcome value that is specified in the navigation component's action attribute. When a user clicks a static navigation button or link, a specific JSF page is always displayed—there are no alternative navigation paths. When a button or link is defined using static navigation, the outcome value in the button's or link's action attribute is a fixed value that always triggers the same navigation case.

To use static navigation, you create the navigation case using a from-outcome value, but not a from-action value. In the action attribute of the button or link you specify a constant outcome value that matches the value you entered in the from-outcome element of the navigation case.

For example, if you create a navigation case with a from-outcome value of Confirm, as shown in Example 9-9, you would create a button or link on the page that specifies Confirm as a static value of the action attribute, as shown in Example 9-10. In this case, when the user clicks the button, the navigation case causes the ConfirmAction page to be displayed.

Example 9-9 Navigation Case Defined in the faces-config.xml File

<navigation-case>
   <from-outcome>Confirm</from-outcome>
   <to-view-id>/app/ConfirmAction.jspx</to-view-id>
</navigation-case>

Example 9-10 Static Navigation Button Defined in a JSF Page

<af:commandButton text="Continue" action="Confirm"/>

9.3.1 How to Create Simple Navigation Components Using Static Outcomes

To create a simple navigation component that uses a static outcome, you can create the component using the Component Palette or the Data Control Palette. If you use the Data Control Palette, the actionListener attribute of the component will be bound to a data control method or operation. Once you have created the component, you can then specify the outcome value in the action attribute. When the user clicks the component, the application navigates to the page determined by the outcome value and navigation case. However, if the component is bound to a data control, first the method or operation is invoked, and then the navigation is performed.

For more information about command components that are bound to data control methods, see Section 10.3, "Creating Command Components to Execute Methods".

To create a simple navigation component that uses a static outcome:

  1. Create a navigation component using one of the following techniques:

    • From the ADF Faces Core page of the Component Palette, drag a CommandButton or a CommandLink component onto the page.


      Tip:

      You can also use the JSF commandButton and commandLink components.

    • From the Data Control Palette, drag a method or operation onto the page and drop it as an ADF Command Button or an ADF Command Link.

  2. In the Structure window, select the navigation component and open the Property Inspector.


    Tip:

    The shortcut for opening the Property Inspector is Ctrl+Shift-I.

  3. In the Action attribute displayed in the Property Inspector, enter the outcome value.

    The value must be a constant or an EL expression that evaluates to a String. To view a list of outcomes already defined in the page's navigation cases, click the dropdown in the Action attribute field of the Property Inspector.


    Tip:

    If you want to trigger a specific navigation case, the outcome value you enter in the action attribute must exactly match the outcome value in the navigation case, including uppercase and lowercase. If the outcome specified by an action does not match any outcome in a navigation case, the navigation will be handled by a default navigation rule (if one exists), or no navigation will occur.

    Also, the action attribute must be either a constant outcome value or an EL expression that evaluates to an outcome value. You cannot enter values such as a URL in the action attribute.


9.3.2 What Happens When You Create a Simple Navigation with Static Outcomes

When you create a navigation component with static outcomes, JDeveloper adds the component to the JSF page. If you have not already done so, you will then need to add a navigation case to the faces-config.xml file to handle the navigation outcome specified in the component.

Example 9-11 shows a simple navigation component that was created using the ADF Faces commandLink component, which is available from the Component Palette. This command link appears on many of the SRDemo application's pages; it navigates to the SRAbout page, which displays information about the application.

Since there is only one possible navigation path, the command link is defined with a static outcome in the action attribute. The outcome value is GlobalAbout, which matches the from-outcome value of the navigation case shown in Example 9-12. The navigation case belongs to a global navigation rule that applies to all pages in the application.

Example 9-11 Simple Navigation Component that Specifies a Static Outcome Value

<af:commandLink text="#{res['srdemo.about']}" action="GlobalAbout"                              immediate="true"/>

Example 9-12 Navigation Rule Referenced by a Static Outcome Value

<navigation-rule>
    <from-view-id>*</from-view-id>
    ...
    <navigation-case>
      <from-outcome>GlobalAbout</from-outcome>
      <to-view-id>/app/SRAbout.jspx</to-view-id>
    </navigation-case>
    ...
</navigation-rule>


Tip:

If you enabled auto-binding by selecting the Automatically Expose UI Components in a New Managed Bean option when you created the page, any navigation component you create will automatically contain a binding to the managed bean (also known as a backing bean) defined for the page, even if the binding is not used. In a simple navigation component that has a static outcome, you may want to remove the unused binding from the component.