| Oracle® Application Development Framework Developer's Guide For Forms/4GL Developers 10g (10.1.3.1.0) Part Number B25947-01 |
|
|
View PDF |
You can create a form that allows users to enter search criteria, execute the search, and then review the results of the search in the same form. However, if the search form includes data types that are other than strings, you will need to create two forms that will act as one: one for the search form, and one for the results.
To do this, you set the form used to enter the search criteria to display only when the iterator is in Find mode. You set the second form, which displays the results, to display only when the iterator is not in Find mode. You control the display of each using an EL expression for the Rendered attribute of the forms. This allows the user to enter in a criteria like > 1500 into a number field when the form is in Find mode, but the same entry will raise an error when the user is editing data.
As stated above, you actually create two forms, one for the query and one for the results. EL expressions are used to determine when to display the correct form.
From the Data Control Palette, drag a collection and from the context menu, select Forms > ADF Search Form.
For example, if you want the query to execute over all service requests, you would drag the ServiceRequests collection.
Drag the same collection, but this time, drop it as an ADF Form. Select Include Navigation Controls in the Edit Form Fields dialog. This will be the form that displays the results. The navigation controls will allow the user to navigate through the objects returned from the query.
In the Structure window, select the panelForm component for the first form.
In the Property Inspector, in the Rendered field, enter the following expression, replacing <iterator> with the name of the iterator:
#{bindings.<iterator>.findMode == true}
This will cause the form to be rendered whenever the iterator is in Find mode.
If you are unsure of the name, you can use the Bind to Data tool to open the Expression Builder, as shown in Figure 18-2.
In the Variables tree of the Expression Builder, select the findMode property under the correct iterator, and click the right arrow to add it to the Expression pane. You then add the logical operator and set the expression to check for true. Figure 18-3 shows the expression that would be built for the ServiceRequestsIterator iterator.
In the Structure window, select the panel form for the second form. Set the Rendered property to:
#{bindings.<iterator_name>.findMode == false}
This expression will cause this form to be displayed whenever the iterator is not in Find mode.
From the Data Control Palette, drag the Find operation associated with the collection and drop it as an ADF Command Button next to the navigation buttons in the second form. This button allows the user to toggle back into Find mode. Doing so will display the first form, so that the user can execute another query.
Rename the Find and Execute buttons to something more meaningful for the user. For example, you might rename the Find button in the top form to Cancel Query, since clicking this button will cause the iterator to toggle out of Find mode. You might rename the Execute button in the top form to Execute Query. Lastly, you might rename the bottom Find button to Enter Query, as that button will be used to place the iterator into Find mode, thereby causing the top form to display.
When you drop a search form onto a page, JDeveloper includes a command button bound to the Find operation and a command button bound to the Execute operation, as shown in Example 18-1. The Find operation places the associated iterator into Find mode. The Execute operation executes the query and places the iterator out of Find mode.
Example 18-1 Page Definition Code for Find and Execute Operations
<action id="Find" RequiresUpdateModel="true" Action="3"
IterBinding="ServiceRequestsIterator"/>
<action id="Execute" RequiresUpdateModel="true" Action="2"
IterBinding="ServiceRequestsIterator"/>
The following table shows the built-in search operations, along with the result of invoking the operation.
Table 18-1 Search Built-in Operations
| Operation | Action Attribute Value | When invoked, the associated iterator binding will... |
|---|---|---|
|
|
3 |
Places the associated iterator into |
|
|
2 |
Applies the criteria and executes the query using the criteria from the iterator when in |
Additionally when you drop an ADF Search Form, JDeveloper adds an outputText component inside the panelGroup component that holds the Find and Execute buttons. This outputText component displays the words Find Mode whenever the iterator is in Find mode. This is used mostly for development purposes, allowing you to be able to easily determine when the iterator is in Find mode. You can safely delete this component.