prain
asked on
How to capture the clicked row number in a p:dataTable from the backer bean?
I have tried this, But I do not get the value printed. Instead an exception. Can someone help?
<p:dataTable id="theTable" var="theTableIterator"
value="#{theBean.jobList}"
selection="#{theBean.selec tedRow}"
rowIndexVar="rowIndex"
widgetVar="datatableVar" >
<p:column>
<p:commandLink value="#{theTableIterator. jobName}"
style="#{theBean.styleStri ng}"
update="theTable"
actionListener="#{theBean. goToClicke dLink()}"
/>
</p:column>
<p:column>
<p:outputLabel value="#{theTableIterator. jobDescrip tion}"
style="#{theBean.styleStri ng}" />
public void goToClickedLink()
{
try {
FacesContext context = FacesContext.getCurrentIns tance();
DataTable dt = (DataTable)
FacesContext.getCurrentIns tance().ge tViewRoot( ).findComp onent("the Table");
System.out.println("Row Index : " + dt.getRowIndex());
}
catch (Exception e) {
}
}
<p:dataTable id="theTable" var="theTableIterator"
value="#{theBean.jobList}"
selection="#{theBean.selec
rowIndexVar="rowIndex"
widgetVar="datatableVar" >
<p:column>
<p:commandLink value="#{theTableIterator.
style="#{theBean.styleStri
update="theTable"
actionListener="#{theBean.
/>
</p:column>
<p:column>
<p:outputLabel value="#{theTableIterator.
style="#{theBean.styleStri
public void goToClickedLink()
{
try {
FacesContext context = FacesContext.getCurrentIns
DataTable dt = (DataTable)
FacesContext.getCurrentIns
System.out.println("Row Index : " + dt.getRowIndex());
}
catch (Exception e) {
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad it worked for you! :)
ASKER