在我的第一页中,我展示了一个加载树表的命令按钮。
树表已显示,但expand node is not working
.
我正在使用 primefaces 4.0,jsf 2.2
这是我的代码,
第一页支持 bean
@ManagedBean(name="loadBean")
public class AjaxLoadBean {
private boolean show;
private String currentPage;
public boolean isShow() {
return show;
}
public void setShow(boolean show) {
this.show = show;
}
public String getCurrentPage() {
return currentPage;
}
public void setCurrentPage(String currentPage) {
this.currentPage = currentPage;
}
public void newPage() {
show = true;
currentPage = "treeTable.xhtml";
}
}
第一页
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<h:form>
<p:commandButton value="Show" actionListener="#{loadBean.newPage}"
update=":content" />
</h:form>
<h:panelGroup id="content">
<h:panelGroup rendered="#{loadBean.show}">
<ui:include src="#{loadBean.currentPage}"></ui:include>
</h:panelGroup>
</h:panelGroup>
</h:body>
</html>
树表.xhtml
我剥离了 ui:composition 标签,
<h:form styleClass="form-horizontal">
<p:treeTable value="#{treeTableBean.root}" var="dataElement"
id="table">
<p:column headerText="No.">
<h:outputText value="#{dataElement.no}" />
</p:column>
<p:column headerText="Name">
<h:outputText value="#{dataElement.name}" />
</p:column>
<p:column headerText="select">
<p:selectBooleanCheckbox value="#{dataElement.select}" />
</p:column>
</p:treeTable>
</h:form>
树表豆
@ManagedBean
public class TreeTableBean implements Serializable{
private static final long serialVersionUID = 1L;
private TreeNode root;
public TreeTableBean() {
root = new DefaultTreeNode("root", null);
new DefaultTreeNode(new TreeTableData(2, "N2", true), root);
new DefaultTreeNode(new TreeTableData(3, "N3", true), root);
new DefaultTreeNode(new TreeTableData(4, "N4", true), root);
TreeNode subNode = new DefaultTreeNode(new TreeTableData(5, "N5", true), root);
new DefaultTreeNode(new TreeTableData(1, "N5.1", true), subNode);
new DefaultTreeNode(new TreeTableData(2, "N5.2", false), subNode);
subNode.setExpanded(true);
}
public TreeNode getRoot() {
return root;
}
}