Java Reference
In-Depth Information
Recall that currentRow is the value of the sourceVar attribute of the <webuijsf:
tableRowGroup> tag in our table. The value of this attribute is used to get a reference
to the current row in the table as it is generated dynamically from a data provider.
The UEL expression #{currentRow} resolves to an instance of com.sun.data.
provider.impl.TableRowDataProvider . This class has a getTableRow() method
that returns an instance of com.sun.data.provider.RowKey . In the above
method, we are invoking this method by using the dot notation of the Unified
Expression Language.
Once we have a reference to the RowKey object for the current row, we need to pass
it to the setSelected() method of our TableSelectPhaseListener instance, since
it uniquely identifies the current row. The second parameter we pass to this method
is the Boolean value that our method receives as a parameter, which indicates if the
current row is selected or not.
Now that we have implemented the logic to set the selected property of each
checkbox in the table, we need to implement the logic to obtain the value of this
property, which needs to be done, of course, in a getter method.
public Boolean getSelected() {
RowKey rowKey = (RowKey) getValue("#{currentRow.tableRow}");
return
(Boolean) tableSelectPhaseListener.getSelected(rowKey);
}
In this method we simply obtain the RowKey instance for the current row the same
way we did in the setter method, then invoke the getSelected() method on our
TableSelectPhaseListener instance, passing the RowKey instance as an argument,
then we return the return value of this method invocation.
By implementing setSelected() and getSelected() methods in our managed
bean, we have actually added a property to our managed bean. We need to bind this
property to the selected property of our checkbox so that our methods are invoked
automatically when the page is rendered. We can do this by right-clicking on
the checkbox either on the design or the Navigator window, then selecting
Property Bindings... .
 
Search WWH ::




Custom Search