Oracle® Application Development Framework Developer's Guide For Forms/4GL Developers 10g (10.1.3.1.0) Part Number B25947-01 |
|
|
View PDF |
For a standard web-type search form, you may not want the user to have to manually place the form into Find
mode. Instead, you may want them to simply enter the search criteria and then execute the search. To do this, you configure the iterator so that it is always in Find
mode. You can then either have the results displayed on a separate page, or you can display them on the same page. If you have them displayed on the same page, you need to create a separate iterator for the results set that is not continually in Find
mode.
To create a search form that is always in find mode, you drop the collection you are searching against as an ADF Search Form, and set a condition on the iterator that keeps it in Find
mode. You then drop the same collection as a table or form on another page to display the results.
To create search and results on separate pages:
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.
On another page, drag the same collection, but this time drop it as any type of table or form.
On the Execute button, create the navigation between the search form and the results page. This will allow the user to navigate to the results page as the query is done. For more information about creating navigation, see Chapter 16, "Adding Page Navigation".
At this point, when the search form on the page renders, it displays with values in the text boxes from the first record. Users must click the Find button in order to set the iterator into Find
mode and enter search criteria. When the user then clicks the Execute button, the user navigates to the results page, whose table displays the results from the query. If the user navigates back to the search form, it displays the attribute values of the first record in the results set.
You can follow the next set of procedures to eliminate the need for the Find button.
To set the iterator automatically in Find mode:
Follow these steps to automatically put the search form's iterator into Find mode:
Open the page definition file for the search page.
In the Structure Pane, right-click on the Executables node and choose Insert inside executables > invokeAction.
In the Insert invokeAction dialog, enter an ID for the action, such as AlwaysFind
. From the Binds drop-down list, select Find. Do NOT click OK or close the dialog.
In the Insert invokeAction dialog, select the Advanced Properties tab.
For Refresh Condition, enter the following EL expression, which tells the application to invoke this Find action whenever the page is not in Find
mode. Replace <iterator> with the name of the iterator:
${bindings.<iterator>.findMode == false}
In the search JSF page, delete the Find button. Doing this only deletes the component from the JSF page. The binding still exists in the page definition because it is being referenced by the EL expression on the RefreshCondition
.
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. For details, see Section 18.2.2, "What Happens When You Create a Search Form".
You use invokeActions
to invoke an operation implicitly. For example, in a search page, instead of needing to have the user click the Find button, you can invoke this operation at a defined time or when a defined condition evaluates to true
.
The RefreshCondition
attribute provides a condition for invoking the action. The Refresh
attribute determines at what point in the ADFm lifecycle the action should be invoked, when the RefreshCondition
evaluates to true
. For a web-type search page, you use an EL expression that evaluates to a condition that says to invoke the Find
action whenever the iterator is not in Find
mode. For example the page definition for the SRSearch page has the following entries:
Example 18-2 Page Definition Code for a Find InvokeAction and Related Binding
<executables> <invokeAction id="AlwaysFind" Binds="Find" Refresh="ifNeeded" RefreshCondition= "${bindings.SearchServiceRequestsIterator.findMode == false}"/> <iterator id="SearchServiceRequestsIterator" RangeSize="10" Binds="SearchServiceRequests" DataControl="SRService"/> </executables> ... <bindings> ... <action id="Find" RequiresUpdateModel="true" Action="3" IterBinding="SearchServiceRequestsIterator"/> ... </bindings>
By creating a condition that places the iterator in continuous Find
mode, any other binding that references that iterator will also be referencing the iterator when it is in Find
mode. Therefore, if you want to have other components on the page that also need to reference that iterator, but do not need it to be in Find
mode, you must create a separate iterator based on the same collection. This is how you are able to place the search results on the same page as the search form. See the next section Chapter 18, "About Creating Search and Results on the Same Page" for details.
As stated above, when you place the iterator into Find
mode, it is in Find
mode for all associated bindings. When you drop the same collection as a table to display the search results, that table's binding uses the same iterator as the search form. Because that means the table component would be bound to an iterator binding in Find
mode, it will display the current query-by-example view criteria rows, as shown in Figure 18-4, instead of the actual data until you hit Execute and the iterator is taken out of Find
mode.
To avoid this, you must create a second iterator for the table that is not in Find
mode, but instead displays the collection of data that meets the search criteria.
To create a page that has both a search form and results table on the same page, you follow the procedures for when they are on separate pages, except you must create a separate iterator for the results table.
To create a search form and results table on the same page:
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 any type of table.
Open the associated page definition file.
In the Structure Pane, right-click on the Executables node and choose Insert inside executables > invokeAction.
In the Insert invokeAction dialog, enter an ID for the action, such as AlwaysFind.
From the Binds drop-down list, select Find. Do NOT click OK or close the dialog.
In the Insert invokeAction dialog, select the Advanced Properties tab.
For RefreshCondition, enter the following EL expression, which tells the application to invoke this action whenever the page is not in Find
mode. Replace <iterator> with the name of the iterator:
${bindings.<iterator>.findMode == false}
Note: TheinvokeAction must appear before the iterator, so that it is executed first. |
In the Structure Pane, right-click on the Executables node and choose Insert inside executables > iterator.
Select the same collection used for the search form, and in the Iterator ID field enter a more meaningful name, such as ResultsIterator and click OK.
In the Structure Pane, expand the bindings node, right-click on the binding for the results table, and choose Properties.
In the Table Binding Editor dialog, make sure the correct collection is selected in the Data Collection column.
Select the newly created iterator from the Iterator drop-down list, ensure that all correct attributes are in the Display Attributes column, and click OK.
In the JSF page, delete the Find button.
Doing this only deletes the component from the JSF page. The binding still exists in the page definition file.
In the above steps, you created a new iterator for the table. This iterator was created using the same collection, however it does not have a find operation associated with it. Therefore, it will always display the results of the search.
For example, the page definition for SRSearch page has the following entries:
Example 18-3 Two Iterators Used to Create a Search Form and Results Table
<executables> <invokeAction id="AlwaysFind" Binds="Find" Refresh="ifNeeded" RefreshCondition= "${bindings.SearchServiceRequestsIterator.findMode == false}"/> ... <iterator id="SearchServiceRequestsIterator" RangeSize="10" Binds="SearchServiceRequests" DataControl="SRService"/> <iterator id="SearchServiceRequestsResultsIterator" RangeSize="10" Binds="SearchServiceRequests" DataControl="SRService" /> . . . </executables> . . . <bindings> . . . <action id="Find" RequiresUpdateModel="true" Action="3" IterBinding="SearchServiceRequestsIterator" . . . <table id="AllServiceRequests" IterBinding="AllServiceRequestsResultsIterator"> . . . </table> </bindings>