【发布时间】:2013-03-23 04:12:03
【问题描述】:
我在一个 xhtml 中使用 p:tree,它动态包含在另一个 xhtml 的 tabview 中。当我们交替更改选项卡时,树扩展不起作用。我无法通过单击节点旁边的图标来展开树。
注意: 或者它不起作用。仅当 index.xhtml 中的 tabview 的 dynamic="true" 和 cache="false" 时才会出现问题。完整的代码如下,场景很容易重现。
由于我在项目的许多地方都使用 p:tree,如果这是一个错误,我要求任何人至少提供一个临时解决方法。我已经在 primefaces 论坛上发布了这个。我在 Tomcat 7.0 上使用带有 JSF 的 Primefaces 3.5
index.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:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<p:tabView dynamic="true" cache="false">
<p:tab title="One">
<ui:include src="/one.xhtml" />
</p:tab>
<p:tab title="two" />
</p:tabView>
</h:body>
</html>
one.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<p:tree widgetVar="treeStructure" value="#{treeBean.root}" var="node" selectionMode="single" id="tree">
<p:treeNode>
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
</h:body>
</html>
TreeBean.java
@ManagedBean
@SessionScoped
public class TreeBean {
private TreeNode root;
public TreeNode getRoot() {
return root;
}
public void setRoot(TreeNode root) {
this.root = root;
}
public TreeBean() {
root = new DefaultTreeNode("Root", null);
TreeNode node0 = new DefaultTreeNode("Node 0", root);
TreeNode node00 = new DefaultTreeNode("Node 0.0", node0);
}
}
【问题讨论】:
-
浏览器中是否检测到任何javascript错误?
-
不,正如我在请求处理期间以及尝试扩展时在 firebug 中注意到的那样。
标签: primefaces