现在我使用Primefaces 5.1。在我的dataTable中设置焦点paginator。要查找指定dataTable到setFirst.But我想知道 dataTable widgetVar 执行相同的过程吗?
stud.xhtml
<p:dataTable value="#{stud.nameList} var="std" widgetVar="mainDataTable">
......
</p:dataTable>
stud.java
public void setPageDataTable() {
final DataTable d = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
.findComponent("form:templateTable");
int first = 1;
if (d.getRowCount() % ROWS_DATATABLE == 0) {
first = (d.getRowCount() - ROWS_DATATABLE);
}
else
{
first = (d.getRowCount()/ROWS_DATATABLE)*ROWS_DATATABLE;
}
d.setFirst(first);
}