data table: rowOnClick

hi, i need to run a bean when i click in a row of the datatable (Tomahawk impl). Is it possible to write it as property in the data table line? ex: <t:dataTable ... rowOnClick="#{bean.method}">Any other ideas are welcome!Thanks for all!
[263 byte] By [javisa81a] at [2007-11-26 20:14:00]
# 1

You can bind the datatable to backing bean component and then use the getRowData method to get the row data(which was clicked). Here is an example.

<h:dataTable value="#{b_empByNameList.names}" var="emp" id="dataTable"

binding="#{b_empByNameList.dataTable}">

<h:commandLink action="#{b_empByNameList.getEmployee}">

<h:outputText value="#{emp.employeeId}"/>

</h:commandLink>

In the Backing Bean

private HtmlDataTable dataTable;

// component binding..

public void setDataTable(HtmlDataTable dataTable) {

this.dataTable = dataTable;

}

public HtmlDataTable getDataTable() {

return dataTable;

}

// this method gets called when the command link is clicked

public String getEmployee() {

Employee empObj = (Employee)this.getDataTable().getRowData();

// do your row processing here...

}

Jatin_Kulkarnia at 2007-7-9 23:20:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...