我想用 primefaces 树元素创建时间线。我有月份名称列表。我想把这个列表放到每年的列表中,如下图所示。
我正在使用 jsf 和 ManagedBean 名称 TreeBean。
我的jsf:
enter code here <h:form id="tmLine">
<div style="width:30%; float:left; ">
<p:tree id="treeSingle" value="#{treeBean.root}" var="node"
style="border:none; border-right:1px solid #aaa;width:100%; border-radius:0px;background:#fff; font-size:100%; "
selectionMode="single"
selection="#{treeBean.selectedNode}" animate="true" >
<p:ajax event="select" update=":tmLine:info"/>
<p:treeNode>
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
</div>
<div style="width:69%; float:left; margin-left:1%;">
<h:outputText value="#{treeBean.testt}" id="info"/>
</div>
<div style="clear:both"/>
</h:form>
树豆是:
enter code here public class TreeBean{
private TreeNode root;
private TreeNode selectedNode;
public TreeBean() {
root = new DefaultTreeNode("Root", null);
TreeNode node0 = new DefaultTreeNode("2011", root);
TreeNode node1 = new DefaultTreeNode("2012", root);
TreeNode node2 = new DefaultTreeNode("2013", root);
TreeNode node00 = new DefaultTreeNode("Ýanwar", node0);
TreeNode node01 = new DefaultTreeNode("Fewral", node0);
TreeNode node02 = new DefaultTreeNode("Mart", node0);
TreeNode node03 = new DefaultTreeNode("Aprel", node0);
TreeNode node04 = new DefaultTreeNode("Maý", node0);
TreeNode node05 = new DefaultTreeNode("Iýun", node0);
TreeNode node06 = new DefaultTreeNode("Iýul", node0);
TreeNode node07 = new DefaultTreeNode("Awgust", node0);
TreeNode node08 = new DefaultTreeNode("Sentýabr", node0);
TreeNode node09 = new DefaultTreeNode("Oktýabr", node0);
TreeNode node10 = new DefaultTreeNode("Noýabr", node0);
TreeNode node11 = new DefaultTreeNode("Dekabr", node0);
TreeNode node100 = new DefaultTreeNode("Node 1.0.0", node10);
}
public TreeNode getRoot() {
return root;
}
public TreeNode getSelectedNode() {
return selectedNode;
}
public void setSelectedNode(TreeNode selectedNode) {
this.selectedNode = selectedNode;
}
public void displaySelectedSingle(ActionEvent event) {
if(selectedNode != null) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Selected", selectedNode.getData().toString());
FacesContext.getCurrentInstance().addMessage(null, message);
}
}
public String getTestt()
{
if(selectedNode!=null)
return selectedNode.getData().toString()+" of 2011 ............Events....";
else
return "";
}
}