Tenho um layout padrão: menu, cabeçalho, rodapé e conteúdo. Estou utilizando Facelets/RichFaces e o componente panelMenu.
Quando eu clico no menu o painel não é atualizado. Vi um problema parecido e tentei utilizar a solução, mas não funciona.
Gostaria da ajuda de vocês para resolver o problema.
Segue os códigos:
menu.xhtml
[code]<?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:h=“http://java.sun.com/jsf/html”
xmlns:f=“http://java.sun.com/jsf/core”
xmlns:a4j=“http://richfaces.org/a4j”
xmlns:rich=“http://richfaces.org/rich”
xmlns:ui=“http://java.sun.com/jsf/facelets”>
<head>
<link href="./css/menu.css" rel=“stylesheet” type=“text/css” />
</head>
<body>
<h:form id=“form1”>
<f:subview id=“subMenu”>
<h:panelGrid columns=“2” columnClasses=“cols” width=“100%”>
<rich:panelMenu style=“width:186px” mode=“ajax”
iconExpandedGroup=“disc” iconCollapsedGroup=“disc”
iconExpandedTopGroup=“chevronUp” iconGroupTopPosition=“right”
iconCollapsedTopGroup=“chevronDown” iconCollapsedTopPosition=“right” >
<rich:panelMenuGroup id=“grpCadastro” label=“Cadastro”>
<rich:panelMenuItem label=“Cliente” action="#{menu.getCorrente}">
<a4j:keepAlive beanName=“menu” />
<f:param name=“corrente” value=“frmCliente.xhtml”/>
</rich:panelMenuItem>
<rich:panelMenuItem id=“Item_1_2” label=“Cidade” action="#{menu.corrente}">
<f:param name=“current” value=“Item 1.2”/>
</rich:panelMenuItem>
<rich:panelMenuItem id=“Item_1_3” label=“Usuário” action="#{panelMenu.updateCurrent}">
<f:param name=“current” value=“Item 1.3”/>
</rich:panelMenuItem>
</rich:panelMenuGroup>
<rich:panelMenuGroup id=“grpOperacoes” label=“Operações”>
<rich:panelMenuItem id=“Item_2_1” label=“Vendas” action="#{panelMenu.updateCurrent}">
<f:param name=“current” value=“Item 2.1”/>
</rich:panelMenuItem>
<rich:panelMenuItem id=“Item_2_2” label=“Orçamento” action="#{panelMenu.updateCurrent}">
<f:param name=“current” value=“Item 2.2”/>
</rich:panelMenuItem>
<rich:panelMenuGroup label=“Group 2.4”>
<rich:panelMenuItem id=“Item_2_4_1” label=“Item 2.4.1” action="#{panelMenu.updateCurrent}">
<f:param name=“current” value=“Item 2.4.1”/>
</rich:panelMenuItem>
</rich:panelMenuGroup>
<rich:panelMenuItem id=“Item_2_5” label=“Item 2.5” action="#{panelMenu.updateCurrent}">
<f:param name=“current” value=“Item 2.5”/>
</rich:panelMenuItem>
</rich:panelMenuGroup>
<rich:panelMenuGroup id=“Group3” label=“Group 3”>
<rich:panelMenuItem id=“Item_3_1” label=“Item 3.1” action="#{panelMenu.updateCurrent}">
<f:param name=“current” value=“Item 3.1”/>
</rich:panelMenuItem>
<rich:panelMenuItem id=“Item_3_2” label=“Item 3.2” action="#{panelMenu.updateCurrent}">
<f:param name=“current” value=“Item 3.2”/>
</rich:panelMenuItem>
<rich:panelMenuItem id=“Item_3_3” label=“Item 3.3” action="#{panelMenu.updateCurrent}">
<f:param name=“current” value=“Item 3.3”/>
</rich:panelMenuItem>
</rich:panelMenuGroup>
</rich:panelMenu>
<rich:panel>
<a4j:outputPanel ajaxRendered=“true”>
<h:outputText value="#{menu.corrente} selected" id=“current”/>
</a4j:outputPanel>
</rich:panel>
</h:panelGrid>
</f:subview>
</h:form>
</body>
</html> [/code]
o código da xhtml - principal
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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:a4j="http://richfaces.org/a4j"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Insert title here </title>
</head>
<body>
<ui:composition template="modelo.xhtml">
<ui:define name="menu">
<ui:include src="menu.xhtml" />
</ui:define>
<ui:define name="conteudo">
<a4j:outputPanel ajaxRendered="true">
<a4j:include viewId="#{menu.corrente}"/>
</a4j:outputPanel>
</ui:define>
<ui:define name="rodape">Desenvolvido por: Woodpecker</ui:define>
</ui:composition>
</body>
</html>
Bean
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package br.appbcs.view;
/**
*
* @author neves
*/
public class menu {
private String corrente;
/** Creates a new instance of menu */
public menu() {
this.setCorrente("frmPadrao.xhtml");
}
/**
* @return the corrente
*/
public String getCorrente() {
return corrente;
}
/**
* @param corrente the corrente to set
*/
public void setCorrente(String corrente) {
this.corrente = corrente;
}
}