Skip Headers
Oracle® Application Development Framework Developer's Guide For Forms/4GL Developers
10g (10.1.3.1.0)

Part Number B25947-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

17.4 Setting Parameter Values Using a Command Component

There may be cases where an action on one page needs to set parameters that will be used to determine application functionality. For example, the results table on the SRSearch page will display only if the value of the searchFirstTime flag on the userState managed bean is false. When this bean is instantiated as the search page is rendered, the isSearchFirstTime method on the bean checks that parameter. If it is null (which it will be the first time the page is rendered), the bean sets the value to true.

A setActionListener component, which is nested in the command button used to execute this search, is then used to set the searchFirstTime flag to false, thus causing the results table to display once the search is executed. For information about using managed beans, see Section 17.2.1, "How to Use a Managed Bean to Store Information".

17.4.1 How to Set Parameters Using Command Components

You can use the setActionListener component to set values on other objects. This component must be a child to a command component.

To use the setActionListener component:

  1. Create a command component using either the Data Control Palette or the Component Palette.

  2. From the Component Palette, drag a setActionListener component and drop it as a child to the command component.

  3. In the Insert ActionListener dialog, set From to be the parameter value.

  4. Set To to be where you want to set the parameter value.


    Tip:

    Consider storing the parameter value on a managed bean or in scope instead of setting it directly on the resulting page's page definition file. By setting it directly on the next page, you lose the ability to easily change navigation in the future. For more information, see Section 17.2, "Using a Managed Bean to Store Information". Additionally, the data in a binding container is valid only during the request in which the container was prepared. Therefore, the data may change between the time you set it and the time the next page is rendered

17.4.2 What Happens When You Set Parameters

The setActionListener component lets the command component set a value before navigating. When you set the From attribute to the source of the value you need to pass, or the actual value, the component will be able to access that value. When you set the To attribute to a target, the command component is able to set the value on the target. Example 17-5 shows the code on the JSF page for a command component that takes the value false and sets that as the value of the searchFirstTime flag on the userState managed bean.

Example 17-5 JSF Page Code for a Command Button Using a setActionListener Component

<af:commandButton actionListener="#{bindings.Execute.execute}"
                 text="#{res['srsearch.searchLabel']}">
  <af:setActionListener from="#{false}"
                           to="#{userState.searchFirstTime}"/>
</af:commandButton>

17.4.3 What Happens at Runtime

When a user clicks the command component, before navigation occurs, the setActionListener component sets the parameter value. In Example 17-5, the setActionListener takes the value false and sets it as the value for the searchFirstTime attribute on the userState managed bean. Now, any component that needs to know this value in determining whether or not to render, can access it using the EL expression #{userState.searchFirstTime}. For the complete example Section 18.5, "Conditionally Displaying the Results Table on a Search Page".