这是我第一次尝试使用JSCookMenu并且其主页(http://jscook.yuanheng.org/JSCookMenu/)已经停止了一个多星期,所以请原谅我,如果我的问题的答案应该出现在那里。
我有一个简单的Web应用程序,为了测试JSCookMenu的动作转发到新的JSF页面而被剥离。
我有一个带有JSCookMenu(Apache MyFaces Tomahawk标签)的管理页面,其中有2个菜单项,'Home Without AL'和'Home with AL'。我希望当我点击这些菜单项时,我将导航到“主页”页面,它现在只显示一个“Hello World”消息。但是,这种导航没有发生。推动正确的方向将非常感激: - )
这是我的faces-config,我的管理页面(使用布局页面),我的主页,我的web.xml(带有过滤器映射)以及当我点击菜单项时会发生什么的描述。
faces-config.xml中:
<!-- Copyright 2004-2006 Sun Microsystems, Inc. All rights reserved.
SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. -->
<faces-config 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"
version="1.2">
<!-- from project setup -->
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>
<navigation-rule>
<navigation-case>
<from-outcome>go_home</from-outcome>
<to-view-id>/home.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
layout.xhtml:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:m="http://code.google.com/p/gmaps4jsf/">
<head>
<title>
<ui:insert name="title">Beach Water Quality</ui:insert>
</title>
<!-- JSCook Menu -->
<script language="JavaScript" src="jscookmenu/JSCookMenu.js" type="text/javascript" />
<script language="JavaScript" src="jscookmenu/ThemeOffice/theme.js" />
<link rel="stylesheet" href="jscookmenu/ThemeOffice/theme.css" type="text/css" />
<script language="JavaScript" src="jscookmenu/ThemeMiniBlack/theme.js" />
<link rel="stylesheet" href="jscookmenu/ThemeMiniBlack/theme.css" type="text/css" />
<script language="JavaScript" src="jscookmenu/ThemeIE/theme.js" />
<link rel="stylesheet" href="jscookmenu/ThemeIE/theme.css" type="text/css" />
<script language="JavaScript" src="jscookmenu/ThemePanel/theme.js" />
<link rel="stylesheet" href="jscookmenu/ThemePanel/theme.css" type="text/css" />
<script language="JavaScript" src="jscookmenu/ThemeGray/theme.js" />
<link rel="stylesheet" href="jscookmenu/ThemeGray/theme.css" type="text/css" />
<script language="JavaScript" src="jscookmenu/ThemeOffice2003/theme.js" />
<link rel="stylesheet" href="jscookmenu/ThemeOffice2003/theme.css" type="text/css" />
</head>
<body onLoad="#{onload}">
<h:panelGrid id="container_div" forceId="true" >
<ui:insert name="header">
<ui:include src="header.xhtml"/>
</ui:insert>
<ui:insert name="content">
<!-- include default content in here -->
</ui:insert>
<ui:insert name="footer">
<ui:include src="footer.xhtml"/>
</ui:insert>
</h:panelGrid>
</body>
</html>
admin.jsp:
<jsp:forward page="admin.jsf"/>
admin.xhtml:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:m="http://code.google.com/p/gmaps4jsf/"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:t="http://myfaces.apache.org/tomahawk" >
<ui:composition template="/WEB-INF/layout/layout.xhtml">
<ui:define name="content">
<f:view contentType="text/html">
<h:form id="form" >
<t:jscookMenu layout="vbr" theme="ThemeIE">
<t:navigationMenuItem itemLabel="Home" itemValue="go_home" action="go_home"/>
</t:jscookMenu>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</html>
针对home.jsp:
<jsp:forward page="/home.jsf"/>
home.xhtml:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:m="http://code.google.com/p/gmaps4jsf/"
xmlns:c="http://java.sun.com/jstl/core" >
<ui:composition template="/WEB-INF/layout/layout.xhtml">
<ui:define name="content">
<f:view contentType="text/html">
<h:form id="form" >
<h:outputText value="Hello World"/>
</h:form>
</f:view>
</ui:define>
</ui:composition>
</html>
的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<description>Beachwater web.xml</description>
<!-- Use Documents Saved as *.xhtml -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<!-- Special Debug Output for Development -->
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<!-- Optional JSF-RI Parameters to Help Debug -->
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>true</param-value>
</context-param>
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</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>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<!-- This is for File Upload -->
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<description>Set the size limit for uploaded files.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB
</description>
<param-name>uploadMaxFileSize</param-name>
<param-value>20m</param-value>
</init-param>
<init-param>
<description>
Set the threshold size - files below this limit are stored
in memory, files above this limit are stored on disk.
Format: 10 - 10 bytes
10k - 10 KB
10m - 10 MB
1g - 1 GB
</description>
<param-name>uploadThresholdSize</param-name>
<param-value>100k</param-value>
</init-param>
<init-param>
<description>
Set the path where the intermediary files will be stored.
</description>
<param-name>uploadRepositoryPath</param-name>
<param-value>/temp</param-value>
</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>
我在我的类路径中有tomahawk12-1.1.9.jar(也尝试过tomahawk-1.1.9.jar),我是从http://myfaces.apache.org/tomahawk/download.html下载的。
我的webapp根目录下有一个jscookmenu文件夹,其中包含每个主题的文件夹(每个主题都有theme.css和theme.js),effect.js和来自jscookmenu-2.0.4.zip的JSCookMenu.js,我从http://sourceforge.net/projects/jscook/files/下载的所有内容。最新发布时间为2009-05-25。
Web应用程序部署在localhost上的Sun GlassFish Enterprise Server v2.1上 我浏览到http://localhost:8080/beachwater/admin.jsp并单击主菜单项 打开新窗口,地址栏“http://localhost:8080/beachwater/form_j_id7_menu:A%5Dgo_home”和内容,“Glassfish错误页面,HTTP状态404:请求的资源()不可用。”
没有任何内容写入server.log
该窗口由JSCookMenu.js中的cmItemMouseUp函数打开。我有错误的javascript版本吗?任何想法为什么过滤器没有调用faces-config中指定的操作?
答案 0 :(得分:1)
事实证明,http://myfaces.apache.org/tomahawk-project/tomahawk12/tagdoc/t_jscookMenu.html上的“说明”部分已过时。不再需要......
......因为这些现在包含在战斧罐中。所以我从webapp的根目录中删除了前面提到的jscookmenu文件夹,以及layout.xhtml的负责人:
<!-- JSCook Menu -->
<script language="JavaScript" src="jscookmenu/JSCookMenu.js" type="text/javascript" />
<script language="JavaScript" src="jscookmenu/ThemeOffice/theme.js" />
<link rel="stylesheet" href="jscookmenu/ThemeOffice/theme.css" type="text/css" />
etc.
我还没有在web.xml中的过滤器映射中包含* .jsp,所以我添加如下:
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
到目前为止,菜单已在页面上呈现。
当我尝试从一个页面导航到另一个页面时,我收到了这个错误:
dummyForm.elements.jscook_action is undefined
,我按照http://forums.sun.com/thread.jspa?forumID=427&threadID=761310的建议将其添加到admin.jsp解决了这个问题:
<input type="hidden" id="jscook_action" name="jscook_action" />
希望这对某人有所帮助,因为JSCookMenu网站仍处于停滞状态,其他地方的帮助似乎相当薄弱。