我在 primefaces 中有一个数据表,我想在其中添加一行时查看数据表的最后一页。
我的 .xhtml 页面是:
<h:form id=...>
...
<p:dataTable var="webTemplate" id="templateTable" widgetVar="tbl1"/>
...
</h:form>
<h:form id=...>
...
<p:inputText id="txt_description" value="#{templateController.templateDescription}" label="templateDescription">
<f:validateLength for="txt_name" minimum="1"/>
<p:ajax event="change"
listener="#{calculatePageTable.setPageTableTemplate}" onsuccess="setTabIndexTT()"/>
</p:inputText>
...
</h:form>
<script type="text/javascript">
function setTabIndexTT(){
tbl1.getPaginator().setPage(#{calculatePageTable.pageTableTemplate});
}
</script>
豆:
@ManagedBean
@SessionScoped
public class CalculatePageTable {
private int pageTableTemplate = 0;
private int pageTableField = 0;
public void setPageTableTemplate() {
final DataTable d = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
.findComponent("form:templateTable");
pageTableTemplate = d.getPageCount() - 1;
}
public int getPageTableTemplate() {
return pageTableTemplate;
}
public void setPageTemplateField() {
final DataTable d = (DataTable) FacesContext.getCurrentInstance().getViewRoot()
.findComponent("detailsTable:webTemplateUpdateTable");
pageTableField = (d.getPageCount() - 1);
}
public int getPageTableField() {
return pageTableField;
}
}
但是onsuccess ajax永远不会调用js函数setTabIndexTT()......
添加行时如何设置数据表的最后一页?
Primefaces 版本是 3.1.1