Oracle® Application Development Framework Developer's Guide
10g Release 3 (10.1.3) B25386-01 |
|
![]() Previous |
![]() Next |
There may be cases where you need to programmatically set the current row for an object on an iterator. For example, the SRList page in the SRDemo application uses command links as shown in Figure 7-8, which the user can click in order to directly edit a service request, without needing to first select the row.
While using command links saves a step for the user, command links do not offer the same functionality as the selection
facet, in that they can neither determine nor set the current row on the iterator. Therefore, you must manually set the current row.
You use the setCurrentRowWithKey
or setCurrentRowWithKeyValue built-in operations to set the current row. These operations are built-in methods on any iterator for a collection. The setCurrentRowWithKey
operation allows you to set the current row given "stringified" key. The setCurrentRowWithKeyValue
operation allows you to set the current row given the a primary key's value.
While you can drop these operations as any type of command component, the commandLink
component is most usually used in this situation. The following procedure explains how to use this component with the setCurrentRowWithKey
and setCurrentRowWithKeyValue
operations.
From the Data Control Palette, drag the setCurrentRowWithKey
or setCurrentRowWithKeyValue
operation.
From the context menu, choose Operations > ADF Command Link.
In the Action Binding Editor, you need to set the value for the rowKey
parameter. By default, it is set to ${bindings.setCurrentRowWithKey_rowKey}
. The actual value should be something that can be used to determine the current row.
For example, the command link in Figure 7-8 needs to set the current row to the same row as the link being clicked. To access the "stringified" key of the row for the setCurrentRowWithKey
operation, you can use the rowKeyStr
property on the binding, or #{row.rowKeyStr}
.
Alternatively, if you use the setCurrentRowWithKeyValue
operation, you might set the rowKey
to the value of the current row, or #{row.svrId}
For more information about the variable used to set the current row on a table (in this case, row
), see Section 7.2.2.2, "Code on the JSF Page for an ADF Faces Table".
When you use the setCurrentRowWithKey
operation as a command component, JDeveloper creates an action binding for that operation. Because this operation takes a parameter (rowKey
) to determine the current row, it has a NamedData
element used to set that value (for more information about parameters and the NamedData
element, see Section 10.3, "Creating Command Components to Execute Methods"). Example 7-11 shows the code on the page definition file created when you drop the setCurrentRowWithKey
operation and set #{row.svrId}
as the value for the rowKey
parameter.
Example 7-11 Page Definition Code for the setCurrentRowWithKey
Operation
<action id="setCurrentRowWithKey" IterBinding="findServiceRequestsIter" InstanceName="SRPublicFacade.dataProvider" DataControl="SRPublicFacade" RequiresUpdateModel="false" Action="96"> <NamedData NDName="rowKey" NDValue="${row.rowKeyStr}" NDType="java.lang.String"/> </action>
When a user clicks the command link, the setCurrentRowWithKey
operation is executed on the iterator, using the rowKey
parameter to determine the current row. As with the tableSelectOne
component, if you use the same iterator to display the current record, the correct data will display.
Tip: For functionality similar to that in the SRDemo application, you may need your command link to pass a parameter value that represents the current row. This value might be used by the method used to create the ensuing form. For more information and procedures, see Section 10.4, "Passing Parameter Values to Another Page Using a Command Component". |