Pessoal estou começando a mexer com JSF.
Gostaria de colocar um menu dinamico na pagina e vi um exemplo com “jscook”.
DynamicMenuTest
import java.util.ArrayList;
import org.apache.myfaces.custom.navmenu.NavigationMenuItem;
public class DynamicMenuTest {
private NavigationMenuItem[] navItems;
public DynamicMenuTest() {
// Criando os Menus Raizes
NavigationMenuItem primeiroMenu = new NavigationMenuItem("Primeiro Menu",null,"/imagens/myfaces.gif",false);
NavigationMenuItem segundoMenu = new NavigationMenuItem("Segundo Menu","ALGUMA_ACAO","/imagens/myfaces.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 subItensPrimeiroMenu = new ArrayList();
subItensPrimeiroMenu.add(new NavigationMenuItem("PRIMEIRO NIVEL","go_primeiroNivel","/imagens/myfaces.gif",false));
subItensPrimeiroMenu.add(new NavigationMenuItem("SEGUNDO NIVEL","go_segundoNivel","/imagens/myfaces.gif",false));
NavigationMenuItem terceiroSubItem = new NavigationMenuItem("TERCEIRO NIVEL",null,"/imagens/myfaces.gif",true);
subItensPrimeiroMenu.add(terceiroSubItem);
primeiroMenu.setNavigationMenuItems(subItensPrimeiroMenu);
// Agora acrescentando os sub-itens no item TERCEIRO NIVEL
ArrayList subItensTerceiroNivel = new ArrayList();
subItensTerceiroNivel.add(new NavigationMenuItem("OPCAO TERCEIRO NIVEL","ALGUMA_ACAO","/imagens/myfaces.gif",false));
terceiroSubItem.setNavigationMenuItems(subItensTerceiroNivel);
}
public NavigationMenuItem[] getNavItems() {
return navItems;
}
public void setNavItems(NavigationMenuItem[] navItems) {
this.navItems = navItems;
}
}
o meu web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>MyFacesTestes</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
a pagina web:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<t:jscookMenu layout="hbr" theme="ThemeOffice">
<t:navigationMenuItems value="#{dynamicMenuTest.navItems}" />
</t:jscookMenu>
</body>
</html>
o erro que aparece é o seguinte:
26/11/2007 13:33:56 org.apache.myfaces.renderkit.html.HtmlRenderKitImpl getRenderer
WARNING: Unsupported component-family/renderer-type: javax.faces.ViewRoot/org.apache.myfaces.JSCookMenu
26/11/2007 13:33:56 org.apache.catalina.core.ApplicationContext log
INFO: No Renderer found for component {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /index2.jsp]} (component-family=javax.faces.ViewRoot, renderer-type=org.apache.myfaces.JSCookMenu)
26/11/2007 13:33:56 javax.faces.component.UIComponentBase getRenderer
WARNING: No Renderer found for component {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /index2.jsp]} (component-family=javax.faces.ViewRoot, renderer-type=org.apache.myfaces.JSCookMenu)
26/11/2007 13:33:56 org.apache.myfaces.renderkit.html.HtmlRenderKitImpl getRenderer
WARNING: Unsupported component-family/renderer-type: javax.faces.ViewRoot/org.apache.myfaces.JSCookMenu
26/11/2007 13:33:56 org.apache.catalina.core.ApplicationContext log
INFO: No Renderer found for component {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /index2.jsp]} (component-family=javax.faces.ViewRoot, renderer-type=org.apache.myfaces.JSCookMenu)
26/11/2007 13:33:56 javax.faces.component.UIComponentBase getRenderer
WARNING: No Renderer found for component {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /index2.jsp]} (component-family=javax.faces.ViewRoot, renderer-type=org.apache.myfaces.JSCookMenu)
26/11/2007 13:33:56 org.apache.myfaces.renderkit.html.HtmlRenderKitImpl getRenderer
WARNING: Unsupported component-family/renderer-type: javax.faces.ViewRoot/org.apache.myfaces.JSCookMenu
26/11/2007 13:33:56 org.apache.catalina.core.ApplicationContext log
INFO: No Renderer found for component {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /index2.jsp]} (component-family=javax.faces.ViewRoot, renderer-type=org.apache.myfaces.JSCookMenu)
26/11/2007 13:33:56 javax.faces.component.UIComponentBase getRenderer
WARNING: No Renderer found for component {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /index2.jsp]} (component-family=javax.faces.ViewRoot, renderer-type=org.apache.myfaces.JSCookMenu)
26/11/2007 13:33:56 org.apache.myfaces.renderkit.html.HtmlRenderKitImpl getRenderer
WARNING: Unsupported component-family/renderer-type: javax.faces.ViewRoot/org.apache.myfaces.JSCookMenu
26/11/2007 13:33:56 org.apache.catalina.core.ApplicationContext log
INFO: No Renderer found for component {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /index2.jsp]} (component-family=javax.faces.ViewRoot, renderer-type=org.apache.myfaces.JSCookMenu)
26/11/2007 13:33:56 javax.faces.component.UIComponentBase getRenderer
WARNING: No Renderer found for component {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /index2.jsp]} (component-family=javax.faces.ViewRoot, renderer-type=org.apache.myfaces.JSCookMenu)
26/11/2007 13:33:56 org.apache.myfaces.renderkit.html.HtmlRenderKitImpl getRenderer
WARNING: Unsupported component-family/renderer-type: javax.faces.ViewRoot/org.apache.myfaces.JSCookMenu
26/11/2007 13:33:56 org.apache.catalina.core.ApplicationContext log
INFO: No Renderer found for component {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /index2.jsp]} (component-family=javax.faces.ViewRoot, renderer-type=org.apache.myfaces.JSCookMenu)
26/11/2007 13:33:56 javax.faces.component.UIComponentBase getRenderer
WARNING: No Renderer found for component {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /index2.jsp]} (component-family=javax.faces.ViewRoot, renderer-type=org.apache.myfaces.JSCookMenu)
para essa outra pagina :
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
<!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=ISO-8859-1">
<title>Teste de JSCOOKMENU</title>
</head>
<body>
<f:view>
<h:form>
<input type="hidden" name="jscook_action" />
<t:jscookMenu layout="hbr" theme="ThemeIE" >
<t:navigationMenuItem itemLabel="Arquivo">
<t:navigationMenuItem itemLabel="Serviço" action="go_primeiroNivel" icon="/imagens/icon.gif" />
<t:navigationMenuItem itemLabel="Funcionário" action="go_segundoNivel" icon="/imagens/icon.gif" />
<t:navigationMenuItem itemLabel="Alocar Funcionário" action="go_primeiroNivel" split="true" icon="/imagens/icon.gif" />
</t:navigationMenuItem>
<t:navigationMenuItem itemLabel="Ajuda" action="go_primeiroNivel" />
</t:jscookMenu>
</h:form>
</f:view>
</body>
</html>
Aparece o seguinte erro:
26/11/2007 13:25:11 org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: ExtensionsFilter not correctly configured. JSF mapping missing. JSF pages not covered. Please see: http://myfaces.apache.org/tomahawk/extensionsFilter.html
at org.apache.myfaces.renderkit.html.util.AddResourceFactory.throwExtensionsFilterMissing(AddResourceFactory.java:371)
at org.apache.myfaces.renderkit.html.util.AddResourceFactory.checkEnvironment(AddResourceFactory.java:333)
at org.apache.myfaces.renderkit.html.util.AddResourceFactory.getInstance(AddResourceFactory.java:288)
at org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer.addResourcesToHeader(HtmlJSCookMenuRenderer.java:443)
at org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer.encodeBegin(HtmlJSCookMenuRenderer.java:400)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:515)
at javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:467)
at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:363)
at org.apache.jsp.index_jsp._jspx_meth_t_005fjscookMenu_005f0(index_jsp.java:192)
at org.apache.jsp.index_jsp._jspx_meth_h_005fform_005f0(index_jsp.java:154)
at org.apache.jsp.index_jsp._jspx_meth_f_005fview_005f0(index_jsp.java:121)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:86)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:419)
at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:211)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
26/11/2007 13:25:11 org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.IllegalStateException: ExtensionsFilter not correctly configured. JSF mapping missing. JSF pages not covered. Please see: http://myfaces.apache.org/tomahawk/extensionsFilter.html
at org.apache.myfaces.renderkit.html.util.AddResourceFactory.throwExtensionsFilterMissing(AddResourceFactory.java:371)
at org.apache.myfaces.renderkit.html.util.AddResourceFactory.checkEnvironment(AddResourceFactory.java:333)
at org.apache.myfaces.renderkit.html.util.AddResourceFactory.getInstance(AddResourceFactory.java:288)
at org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer.addResourcesToHeader(HtmlJSCookMenuRenderer.java:443)
at org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer.encodeBegin(HtmlJSCookMenuRenderer.java:400)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:515)
at javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:467)
at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:363)
at org.apache.jsp.index_jsp._jspx_meth_t_005fjscookMenu_005f0(index_jsp.java:192)
at org.apache.jsp.index_jsp._jspx_meth_h_005fform_005f0(index_jsp.java:154)
at org.apache.jsp.index_jsp._jspx_meth_f_005fview_005f0(index_jsp.java:121)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:86)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:419)
at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:211)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Bom então eu vo na pagina indicada. Lá tem uma parte para adicionar no web.xml.
Mas depois que eu adiciono aparece os warning continuam para a pagina com o menu dinamico
web.xml depois
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>MyFacesTestes</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<param-name>maxFileSize</param-name>
<param-value>20m</param-value>
<description>Set the size limit for uploaded files.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB
</description>
</init-param>
</filter>
<!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>
</web-app>
Mas para pagina com menu estatico funciona!
Alguem poderia me ajudar a fazer rodar para os menus dinamicos!
Valeu a ajuda!