Netbeans Visual Web Selecting Rows

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());
}

2 Responses to “Netbeans Visual Web Selecting Rows”

  1. daniel writes:

    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

  2. Chui writes:

    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?

Leave a Reply