jscookMenu + JSF + configuração

4 respostas
derheimen

Galera preciso de um Help de alguém que entenda sobre JSF, pois estou com algumas dúvidas.
Estou implementando uma aplicação utilizando JSF, utilizo o tomahawk-1.1.3.jar e alguns componentes, por exemplo o jscookMenu.
Tenho uma jsp com o seguinte código(index.jsp):

<html>
	<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
	<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
	<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>

	<f:view>
		<f:loadBundle var="text" basename="resource"/>
		<head>
			<title><h:outputLabel value="#{text['index.title']}"/></title>
			<link rel="stylesheet" type="text/css" href="PAGE-INF/css/styles.css"/>
		</head>

		<body>
			<h:form>
				<input type="hidden" name="jscook_action" />
				<table align="center" width="70%" class="header">
					<tr>
						<td align="left">
							<h:graphicImage id="waveImg" url="/PAGE-INF/images/logo.jpg"/>
						</td>
						<td align="right">
							<h:commandLink action="#{index.logoff}" style="cursor:pointer">
								<h:outputLabel value="#{text['index.logoff']}"/>
							</h:commandLink>
						</td>
					</tr>
				</table>
				<table align="center" width="70%">
					<tr>
						<td align="left">
							<%-- 1º MENU: ESTÁTICO --%>
							<t:jscookMenu layout="hbr" theme="ThemeIE" >
								<t:navigationMenuItem itemLabel="Projeto:::..." icon="/PAGE-INF/images/marcador_menu.gif">
									<t:navigationMenuItem itemLabel="Cadastrar Projeto" action="cadProjeto" icon="/PAGE-INF/images/marcador_menu.gif"/>
									<t:navigationMenuItem itemLabel="Alterar Projeto" action="altProjeto" icon="/PAGE-INF/images/marcador_menu.gif"/>
									<t:navigationMenuItem itemLabel="Excluir Projeto" action="excProjeto" icon="/PAGE-INF/images/marcador_menu.gif"/>
									<t:navigationMenuItem itemLabel="Consultar Projeto(s)" split="true" icon="/PAGE-INF/images/marcador_menu.gif">
									<t:navigationMenuItem itemLabel="Por Identificador" action="ALGUMA_ACAO" icon="/PAGE-INF/images/marcador_menu.gif"/>
										<t:navigationMenuItem itemLabel="Todos" action="ALGUMA_ACAO" icon="/PAGE-INF/images/marcador_menu.gif"/>
									</t:navigationMenuItem>
								</t:navigationMenuItem>
								<t:navigationMenuItem itemLabel="Módulos:::..." action="ALGUMA_ACAO" icon="/PAGE-INF/images/marcador_menu.gif" />
							</t:jscookMenu>
							
							<%-- 2º MENU: DINAMICO --%>
							<%--
							ESTE CÓDIGO ESTA COMENTADO

							t:jscookMenu layout="hbr" theme="ThemeOffice">
							    <t:navigationMenuItems value="#{menuDinamico.navItems}" />
							</t:jscookMenu

							--%>
						</td>
					</tr>
				</table>
			</h:form>
		</body>
	</f:view>
</html>

A página esta funciona corretamente.
Obs:Olhe que utilizo o jscookMenu estático e funciona perfeitamente, o segundo esta comentado. Mas quando comento o primeiro jscookMenu estático e utilizo o segundo jscookMenu dinamico ocorre o seguinte erro.

Configurei os arquivos web.xml e faces-config da seguinte forma:
Implementei também a classe MenuDinamico.java
web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5"
		 xmlns="http://java.sun.com/xml/ns/javaee"
		 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

	<display-name>scap</display-name>

	<context-param>
		<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
		<param-value>client</param-value>
	</context-param>

	<context-param>
		<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
		<param-value>ApplicationResources</param-value>
	</context-param>

	<filter>
		<filter-name>HibernateFilter</filter-name>
		<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>HibernateFilter</filter-name>
		<url-pattern>*.faces</url-pattern>
	</filter-mapping>

	<filter>
		<filter-name>ExtensionsFilter</filter-name>
		<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>ExtensionsFilter</filter-name>
		<url-pattern>*.faces</url-pattern>
	</filter-mapping>

	<filter-mapping>
		<filter-name>ExtensionsFilter</filter-name>
		<url-pattern>/faces/*</url-pattern>
	</filter-mapping>

	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	<!-- Faces Servlet -->
	<servlet>
		<servlet-name>facesServlet</servlet-name>
		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<!-- Faces Servlet Mapping -->
	<servlet-mapping>
		<servlet-name>facesServlet</servlet-name>
		<url-pattern>*.faces</url-pattern>
	</servlet-mapping>

	<session-config>
		<session-timeout>10</session-timeout>
	</session-config>

	<welcome-file-list>
		<welcome-file>start.jsp</welcome-file>
	</welcome-file-list>

</web-app>

faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>

<faces-config version="1.2"
			  xmlns="http://java.sun.com/xml/ns/javaee"
			  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
			  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">

	<application>
		<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
		<locale-config>
			<default-locale>pt_br</default-locale>
			<supported-locale>pt_br</supported-locale>
		</locale-config>
		<message-bundle>resources</message-bundle>
	</application>

	<navigation-rule>
		<from-view-id>/index.jsp</from-view-id>
		<navigation-case>
			<from-outcome>cadProjeto</from-outcome>
			<to-view-id>/pages/projeto/ViewCadastrarProjeto.jsp</to-view-id>
		</navigation-case>
		<navigation-case>
			<from-outcome>altProjeto</from-outcome>
			<to-view-id>/pages/projeto/ViewAlterarProjeto.jsp</to-view-id>
		</navigation-case>
	</navigation-rule>

	<navigation-rule>
  		<from-view-id>/pages/projeto/ViewCadastrarProjeto.jsp</from-view-id>
  		<navigation-case>
    		<from-outcome>projCadastrado</from-outcome>
    		<to-view-id>/pages/projeto/ViewCadastrarProjeto.jsp</to-view-id>
  		</navigation-case>
	</navigation-rule>

	<managed-bean>
		<managed-bean-name>menuDinamico</managed-bean-name>
		<managed-bean-class>br.mt.abaco.scap.web.menu.MenuDinamico</managed-bean-class>
		<managed-bean-scope>request</managed-bean-scope>
		<managed-property>
			<property-name>menuManager</property-name>
			<value>#{menuManager}</value>
		</managed-property>
	</managed-bean>

</faces-config>

MenuDinamico.java

package br.mt.abaco.scap.web.menu;

import java.util.ArrayList;
import java.util.List;

import org.apache.myfaces.custom.navmenu.NavigationMenuItem;

import br.mt.abaco.scap.service.MenuManager;

public class MenuDinamico {

	private MenuManager menuManager;

	private NavigationMenuItem[] navItems;

	public MenuDinamico() {
		// Criando os Menus Raizes
		NavigationMenuItem primeiroMenu = new NavigationMenuItem("Projeto:::...",null,"PAGE-INF/images/marcador_menu.gif",false);
		NavigationMenuItem segundoMenu = new NavigationMenuItem("Módulos:::...","alguma_acao","PAGE-INF/images/marcador_menu.gif",false);

		// Agora acrescentando os menus raízes ao array que será retornado ao JSP
		this.navItems = new NavigationMenuItem[2];
		this.navItems[0] = primeiroMenu;
		this.navItems[1] = segundoMenu;

		// Agora acrescentando os itens no menu primeiroMenu
		ArrayList<NavigationMenuItem> subItensPrimeiroMenu = new ArrayList<NavigationMenuItem>();

		subItensPrimeiroMenu.add(new NavigationMenuItem("Cadastrar Projeto","go_primeiroNivel","PAGE-INF/images/marcador_menu.gif",false));
		subItensPrimeiroMenu.add(new NavigationMenuItem("Alterar Projeto","go_segundoNivel","PAGE-INF/images/marcador_menu.gif",false));
		subItensPrimeiroMenu.add(new NavigationMenuItem("Excluir Projeto","go_segundoNivel","PAGE-INF/images/marcador_menu.gif",false));

		NavigationMenuItem terceiroSubItem = new NavigationMenuItem("Consultar Projeto(s)",null,"PAGE-INF/images/marcador_menu.gif",true);
		subItensPrimeiroMenu.add(terceiroSubItem);

		primeiroMenu.setNavigationMenuItems(subItensPrimeiroMenu);

		// Agora acrescentando os sub-itens no item TERCEIRO NIVEL
		ArrayList<NavigationMenuItem> subItensTerceiroNivel = new ArrayList<NavigationMenuItem>();
		subItensTerceiroNivel.add(new NavigationMenuItem("Por Identificador","alguma_acao","PAGE-INF/images/marcador_menu.gif",false));
		subItensTerceiroNivel.add(new NavigationMenuItem("Todos","alguma_acao","PAGE-INF/images/marcador_menu.gif",false));

		terceiroSubItem.setNavigationMenuItems(subItensTerceiroNivel);
	}

	public NavigationMenuItem[] getNavItems() {
		return navItems;
	}

	public void setNavItems(NavigationMenuItem[] navItems) {
		this.navItems = navItems;
	}	

	public MenuManager getMenuManager () {
		return menuManager;
	}

	public void setMenuManager (MenuManager menuManager) {
		this.menuManager = menuManager;
	}

}

Éstou fazendo alguma coisa de errado, se alguém puder me ajudar.
Desde já agradeço.

4 Respostas

Eduardo_Bregaida

Ou vc esqueceu de cadastrar uma lib, ou vc ta usando um metodo passando parametro errado, vc já olhou o log gerado no tomcat, jboss ou o servidor de aplicações q vc está usando?

derheimen

Olha oque o erro que sai no tomcat:

derheimen

Alguém conhece este erro do JSF,

16/03/2007 11:08:03 com.sun.faces.lifecycle.LifecycleImpl phase
WARNING: executePhase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@1afe17b) threw exception
javax.faces.FacesException: org.apache.jasper.JasperException: org.apache.jasper.JasperException: /index.jsp(45,11) According to TLD or attribute directive in tag file, attribute value does not accept any expressions

Ocorre na segunda linha deste código, que fica na página (index.jsp):

<t:jscookMenu layout="hbr" theme="ThemeOffice"> <t:navigationMenuItems value="#{menuDinamico.navItems}" /> </t:jscookMenu

derheimen

O erro esta na tag :
<t:navigationMenuItems value="#{menuDinamico.navItems}" />

especificamente na propriedade
value="#{menuDinamico.navItems}"

Por que será que nãp consegue usar o método

public NavigationMenuItem[] getNavItems() {
	return navItems;
}

???
:frowning: :frowning:

Criado 16 de março de 2007
Ultima resposta 21 de mar. de 2007
Respostas 4
Participantes 2