Oracle® Application Development Framework Developer's Guide For Forms/4GL Developers 10g (10.1.3.1.0) Part Number B25947-01 |
|
|
View PDF |
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 in the second column, as shown in Figure 14-8, which the user can click 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. For more information about the current row operations, see Section 10.5.6, "Understanding the Difference Between setCurrentRowWithKey and setCurrentRowWithKeyValue".
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.
JDeveloper creates the command link component on the page, and adds the action binding to the page definition file. You need to change the value for the rowKey
parameter in the Action Binding Editor.
Select the command link component in the Structure window, and choose Edit Binding from the context menu.
In the Action Binding Editor, by default, the value for the rowKey
parameter 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 14-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 14.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 17.3, "Creating Command Components to Execute Methods").
Example 14-13 shows the code created in the page definition file when you drop the setCurrentRowWithKey
operation and set #{row.rowKeyStr}
as the value for the rowKey
parameter.
Example 14-13 Page Definition Code for the SetCurrentRowWithKey Operation
<action id="setCurrentRowWithKey" IterBinding="ServiceRequestsByStatusIterator" InstanceName="SRService.ServiceRequestsByStatus" DataControl="SRService" 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 17.4, "Setting Parameter Values Using a Command Component". |