I need your help in getting the column values by using the onclick event of the selected row through ajax listener.
The datatable code is:
<p:dataTable id="availableCars" var="car" rowKey="#{car}" value="#{CarsView.carDetails}">
<p:column style="width:20px">
<h:outputText id="dragIcon" styleClass="ui-icon ui-icon-arrow-4"/>
<p:draggable for="dragIcon" revert="true" helper="clone"/>
</p:column>
<p:column headerText="Id">
<h:outputText value="#{car.employeeName}"/>
</p:column>
<p:column headerText="Id">
<h:outputText value="#{car.employeeCode}"/>
</p:column>
<p:column style="width:32px">
<p:commandButton icon="ui-icon-search" action="#{CarsView.getDetails}">
<f:setPropertyActionListener target="#{CarsView.employee}" value="#{car.employeeName}"/>
<f:setPropertyActionListener target="#{CarsView.code}" value="#{car.employeeCode}"/>
<p:ajax event="click" listener="#{CarsView.onclickbutton}"/>
</p:commandButton>
</p:column>
</p:dataTable>
And the code for retrieving the List:
@PostConstruct
public void init() {
cars= new ArrayList<Car>();
droppedCars = new ArrayList<Car>();
Car earn = new Car();
earn.setEmployeeCode("1111");
earn.setEmployeeName("James");
cars.add(earn);
}
public void onclickbutton(ClickEvent event)
{
System.out.println("Clicked");
DataTable objDataTable = (DataTable) event.getSource();
}
In my case how can I access the objects(employeeCode and the employeeName) in the availableCars datatable
in the onclickbutton
method and to get the column values and assign them to variables.