JSF 2.0; Eclipse; PirmeFaces <p:tree> não esta aparecendo

2 respostas
S

Boa tarde pessoal.

Estou com o seguinte problema, preciso utilizar o componente tree do prime faces.
Ao testar o exemplo disponível no manual deles, a arvore não esta aparecendo.

página:

<!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:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui">
<body>
<ui:include src="/webparts/headermenu.xhtml" />
<h:form action="">

	<h:panelGrid columns="2">
		<h:panelGrid columns="1">
			<p:tree value="#{frameMB.root}" var="node">
				<p:treeNode>
					<h:outputText value="#{node}" />
				</p:treeNode>
			</p:tree>
		</h:panelGrid>
		<h:panelGrid columns="1">

		</h:panelGrid>
	</h:panelGrid>

</h:form>
</body>
</html>

managed bean:

package br.com.nattex.web.view.mbeans;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

import org.primefaces.model.DefaultTreeNode;
import org.primefaces.model.TreeNode;

@ManagedBean(name = "frameMB")
@RequestScoped
public class FrameMB {

	private TreeNode root;

	public FrameMB() {
		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;
	}

}

Código Fonte da página (browser):

<!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">
<body>
<form id="j_idt3" name="j_idt3" method="post" action="/infraestruturaWEB/faces/webparts/frame.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt3" value="j_idt3" />

<script type="text/javascript" src="/infraestruturaWEB/faces/javax.faces.resource/jsf.js?ln=javax.faces"></script>
<a id="j_idt3:jLinkSair" href="#" onclick="mojarra.jsfcljs(document.getElementById('j_idt3'),{'j_idt3:jLinkSair':'j_idt3:jLinkSair'},'');return false">Sair</a><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="161713885396302717:-5288599957392127328" autocomplete="off" />
</form>
<form id="j_idt4" name="j_idt4" method="post" action="/infraestruturaWEB/faces/webparts/frame.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt4" value="j_idt4" />
<table>
<tbody>
<tr>
<td><table>

<tbody>
<tr>
<td><div id="j_idt4:j_idt7"><div id="j_idt4:j_idt7_container"></div></div><script type="text/javascript">widget_j_idt4_j_idt7 = new PrimeFaces.widget.TreeView('j_idt4:j_idt7', [
{html:'Node 0',type:'html',rowKey:'0',children:[{html:'Node 0.0',type:'html',rowKey:'0.0',children:[{html:'Node 0.0.0',type:'html',rowKey:'0.0.0',isLeaf:true,children:[]},{html:'Node 0.0.1',type:'html',rowKey:'0.0.1',isLeaf:true,children:[]}]},{html:'Node 0.1',type:'html',rowKey:'0.1',children:[{html:'Node 0.1.0',type:'html',rowKey:'0.1.0',isLeaf:true,children:[]}]}]},{html:'Node 1',type:'html',rowKey:'1',children:[{html:'Node 1.0',type:'html',rowKey:'1.0',children:[{html:'Node 1.0.0',type:'html',rowKey:'1.0.0',isLeaf:true,children:[]}]},{html:'Node 1.1',type:'html',rowKey:'1.1',isLeaf:true,children:[]}]},{html:'Node 2',type:'html',rowKey:'2',isLeaf:true,children:[]}],{dynamic:false,actionURL:'/infraestruturaWEB/faces/webparts/frame.xhtml',formId:'j_idt4',cache:true});
widget_j_idt4_j_idt7.render();
</script></td>
</tr>
</tbody>
</table>
</td>
<td><table>
<tbody>
<tr><td></td></tr></tbody>
</table>
</td>
</tr>
</tbody>
</table>
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="161713885396302717:-5288599957392127328" autocomplete="off" />

</form>
</body>
</html>

Alguem sabe me dizer o porquê de não estar aparecendo a árvore?

Não esta gerando nenhum erro.

Desde já grato,
Filipe D.

2 Respostas

dev.rafael

Kra, tente substituir a tag p/ <h:body> e adicione “<h:head></h:head>”, nem q seja vazio, senão o PrimeFaces não saberá onde ecoar os css e js.

S

Rafael,
muito obrigado cara.
nossa ja estava preso nisto a umas 4h

O <h:body> eu já havia testado, mas o <h:head></h:head> não,
foi só fazer o que você falou que rsolveu.

Muito obrigado.

Criado 29 de setembro de 2010
Ultima resposta 29 de set. de 2010
Respostas 2
Participantes 2