Panel não renderiza em JSF?

0 respostas
felipe.sodre

Boa tarde, estou a horas tentanto renderizar um bendito panel que tem uma jsp:include dentro e nada até agora pelo amor de deus me ajudem.

Meu Bean:

package br.com.sigga.test.tree;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.TreeSet;

import org.richfaces.component.html.HtmlTree;
import org.richfaces.event.NodeSelectedEvent;
import org.richfaces.model.TreeNode;
import org.richfaces.model.TreeNodeImpl;

import br.com.sigga.util.PropertiesLoader;

@SuppressWarnings("unchecked")
public class TreeBean {

	private TreeNode rootNode = null;
	private List<String> selectedNodeChildren = new ArrayList<String>();
	private static String PROPERTIES_NAME = "/resources/tree.properties";
	private String page;
	private ArrayList<String> idAllowedApp;
	private Properties properties;

	public TreeBean() {
		properties = new PropertiesLoader(PROPERTIES_NAME).getProps();
		if (idAllowedApp == null)
			idAllowedApp = getKeyAppAllowed();
	}

	public String getPage() {
		if(page == null)
			page = "config.jsp";
		return page;
	}

	public void setPage(String page) {
		this.page = page;
	}

	private String nodeTitle;

	private void addNodes(String path, TreeNode node, Properties properties) {
		boolean end = false;
		int counter = 1;

		while (!end) {
			String key = path != null ? path + '.' + counter : String
					.valueOf(counter);

			String value = properties.getProperty(key);
			if (value != null) {
				TreeNodeImpl nodeImpl = new TreeNodeImpl();
				nodeImpl.setData(value);
				if (idAllowedApp.contains(key))
					node.addChild(new Integer(counter), nodeImpl);
				addNodes(key, nodeImpl, properties);
				counter++;
			} else {
				end = true;
			}
		}
	}

	private ArrayList<String> getKeyAppAllowed() {
		ArrayList<String> apps = new ArrayList<String>();
		apps.add("Admin".toUpperCase());
		ArrayList<String> result = new ArrayList<String>();
		Enumeration e = properties.propertyNames();
		e = Collections.enumeration(new TreeSet(Collections.list(e)));

		String value = null;
		int cont = 0;

		while (e.hasMoreElements()) {
			value = (String) e.nextElement();
			int aux = Integer.parseInt("" + value.charAt(0));
			if(aux - 1 > cont){
				cont = aux;
			}
			
			if (apps.contains(properties.getProperty(value).toUpperCase())){
				result.add(value);
			}
			else {
				String s = result.get(result.size() -1);
				s = Character.toString(s.charAt(0));
				if (value.startsWith(s)) {
					result.add(value);
				} 
			}
		}

		return result;
	}

	public void processSelection(NodeSelectedEvent event) {
		HtmlTree tree = (HtmlTree) event.getComponent();
		nodeTitle = (String) tree.getRowData();
		selectedNodeChildren.clear();
		TreeNode currentNode = tree.getModelTreeNode(tree.getRowKey());
		if (currentNode.isLeaf()) {
			selectedNodeChildren.add((String) currentNode.getData());
		} else {
			Iterator<Map.Entry<Object, TreeNode>> it = currentNode
					.getChildren();
			while (it != null && it.hasNext()) {
				Map.Entry<Object, TreeNode> entry = it.next();
				selectedNodeChildren.add(entry.getValue().getData().toString());
			}
		}
		page = "login.jsp";
	}

	public TreeNode getTreeNode() {
		if (rootNode == null) {
			rootNode = new TreeNodeImpl();
			addNodes(null, rootNode, properties);

		}

		return rootNode;
	}

	public String getNodeTitle() {
		return nodeTitle;
	}

	public void setNodeTitle(String nodeTitle) {
		this.nodeTitle = nodeTitle;
	}
}

Minha pagina

<%@taglib uri="http://richfaces.org/rich" prefix="rich1"%><%@taglib
	uri="http://richfaces.org/a4j" prefix="a4j"%><%@ page language="java"
	contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://richfaces.ajax4jsf.org/rich" prefix="rich"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<f:view>
	<h:form id="formTree">
			<h:panelGrid columns="2">
				<rich:panel header="Menu Principal" style="width: 180px">
					<rich:tree nodeSelectListener="#{treeBean.processSelection}"
						reRender="pnlPages" ajaxSubmitSelection="true" switchType="client"
						value="#{treeBean.treeNode}" var="item" ajaxKeys="#{null}"
						icon="images/logomenu.png" iconLeaf="images/iconLeaf.png"
						rendered="true">
					</rich:tree>
				</rich:panel>
				<rich:panel header="#{treeBean.page}"
					style="width:100%" id="pnlPages" rendered="true">
					<h:outputText value="PAGINA: #{treeBean.page}"></h:outputText>
					<jsp:include page="#{treeBean.page}" />
				</rich:panel>				
		</h:panelGrid>
	</h:form>
</f:view>
</body>
</html>
Criado 27 de abril de 2010
Respostas 0
Participantes 1