Netbeans Visual Web Selecting Rows
Saturday, 24 March 2007
The UI presentation layer doesn’t hold state about which rows were selected.
Winston Prakash outlines how selecting a single row in Netbeans JSF table can be done, but it was a little roundabout.
Here’s a simpler take on it:
Bind a TableRowGroup’s selected attribute to a property on your page.
<ui:tableRowGroup
binding="#{Page1.tableRowGroup2}"
id="tableRowGroup2"
selected="#{Page1.selected}"
sourceData="#{Page1.myDataProvider}"
sourceVar="currentRow">
Next just write the callback function, in our case, the selected row is the current cursor row, but it could be anything of course:
public boolean getSelected()
{
RowKey rk = (RowKey) getValue("#{currentRow.tableRow}");
return rk.equals(myDataProvider.getCursorRow());
}
No. 1 — August 14th, 2007 at 4:33 am
mmmh, I tried but it throws me this:
Exception Details: org.apache.jasper.JasperException
javax.faces.el.EvaluationException: Error getting property ’selected’ from bean of type testtable.Page1: javax.faces.el.ReferenceSyntaxException: #(currentRow.tableRow)
btw I’m a novice at this
No. 2 — August 14th, 2007 at 8:31 pm
I wasn’t using jasper, just the netbeans implementation of jsf. I’m not sure how jasper implements it’s expression language. I’d have hoped it was the same. Did getSelected() get called at all?