Skip Headers
Oracle® Application Development Framework Developer's Guide
10g (10.1.3.1.0)

Part Number B28967-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

9.3 Using Static Navigation

When a component is defined using static navigation, the outcome value in the action attribute is a constant value that always triggers the same navigation case. When a user clicks a component that is using static navigation, a specific JSF page is displayed—there are no alternative navigation paths.

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 navigation 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 Static Navigation

To create a 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 operation or method. 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 operation or method 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 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 or commandLink components.

    • From the Data Control Palette, drag and drop an operation or a method onto the page and choose ADF Command Button or an ADF Command Link from the context menu.

      If you drag and drop a method that takes parameters, the ADF command button and command link components appear under Method in the context menu. JDeveloper displays the Action Binding Editor where you can define any parameter values you want to pass to the method. For more information about passing parameters to methods, see Section 10.4, "Setting Parameter Values Using a Command Component".

  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 field 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 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 an outcome value or an EL expression that evaluates to an outcome value. You cannot enter a page URL in the action attribute.


9.3.2 What Happens When You Create Static Navigation

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 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 choosing 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.