Primefaces Tree in a layout or panel doesn’t work
I must be losing more hair than anything. The tree function in a layout doesn’t work, although the backing bean is called the selectedItems array passed to it is empty. So here’s the fix.
Your code now looks like this probably (or something like it).
<p:panel style="height:80%"> <p:tree selection="#{indextree.selectedNodes}"
update="Map" propagateSelectionUp="true" propagateSelectionDown="true"
nodeSelectListener="#{indextree.onNodeSelect}" id="tree"
style="font-size:12pt" selectionMode="checkbox" value="#{indextree.root}" var="node"> <p:treeNode> <h:outputText value="#{node}"/> </p:treeNode>
</p:tree>
</p:panel>
So simply create another xhtml file and put the tree in it on it’s own. In this case I called it treeTest.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:p="http://primefaces.prime.com.tr/ui" xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core">
<f:view contentType="text/html"><h:head>
<title>Tracking</title>
</h:head>
<h:body style="font-size:8pt" >
<h:form id="boris" enctype="multipart/form-data">
<p:tree selection="#{indextree.selectedNodes}" update="Map" propagateSelectionUp="true" propagateSelectionDown="true" nodeSelectListener="#{indextree.onNodeSelect}" id="tree" style="font-size:12pt" selectionMode="checkbox" value="#{indextree.root}" var="node">
<p:treeNode>
<h:outputText value="#{node}"/>
</p:treeNode>
</p:tree></h:form></h:body>
</f:view>
</html>
Now in your original file replace your tree code with an iframe! Tada, it all works! (note it should have < at the start and > at the end but wordpress goes a bit mad if I do that.
iframe src="treeTest.xhtml" style="height:80%;border-style:none;border-width:1px;" ></iframe
By the way this is fixed in the latest V3.0M
Posted on October 20, 2011, in Howto, Primefaces. Bookmark the permalink. Leave a Comment.
Leave a Comment
Comments (0)