我是 JSF 编程的新手。我想从 Primefaces 网站实现树视图示例。
JSF 页面
<h:form id="form">
<p:tree value="#{TreeViewController.root}" var="node" dynamic="true" cache="true" id="tree" animate="true">
<p:treeNode>
<h:outputText value="Node"/>
</p:treeNode>
</p:tree>
</h:form>
托管豆
private TreeNode root;
public TreeView() {
root = new DefaultTreeNode("Root", null);
TreeNode node0 = new DefaultTreeNode("Node 0", root);
TreeNode node1 = new DefaultTreeNode("Node 1", root);
TreeNode node2 = new DefaultTreeNode("Node 2", root);
TreeNode node00 = new DefaultTreeNode("Node 0.0", node0);
TreeNode node01 = new DefaultTreeNode("Node 0.1", node0);
TreeNode node10 = new DefaultTreeNode("Node 1.0", node1);
TreeNode node11 = new DefaultTreeNode("Node 1.1", node1);
TreeNode node000 = new DefaultTreeNode("Node 0.0.0", node00);
TreeNode node001 = new DefaultTreeNode("Node 0.0.1", node00);
TreeNode node010 = new DefaultTreeNode("Node 0.1.0", node01);
TreeNode node100 = new DefaultTreeNode("Node 1.0.0", node10);
}
public TreeNode getRoot() {
return root;
}
我想问你这两个问题:当我点击一个节点时如何打开一个新页面?如何将 Java 哈希图作为节点的子节点显示到树中?例如,我想用 Java hashmap 或 Java map 填充树视图。