0
votes

I'm using p:tree inside a xhtml which is included dynamically into a tabview of another xhtml. When we change tabs alternatively tree expansion does not work. I'm unable to expand tree by clicking the icon beside the node.

Note: Alternatively it doesn't work. Problem occurs only when dynamic="true" and cache="false" for the tabview in index.xhtml. Complete code is below using which the scenario is easily reproducible.

As I'm using p:tree in many places of my project, I request anybody to provide at least a temporary workaround if this is a bug. I already posted this in primefaces forum. I'm using Primefaces 3.5 with JSF on Tomcat 7.0

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);
   }
}
1
Is there any javascript error detected in browser? - Jitesh
No, as I noticed in firebug during the request processing as well as when trying to expand. - RAMSY

1 Answers

0
votes

Found the solution. It's simple and obvious but struggled though. Remove <h:head></h:head> tag in one.xhtml which is not necessary and is reloading the required js files which are already loaded and very much available. Just keep <h:head></h:head> tag in main page always. Here it's index.xhtml.