MyFaces Tomahawk JSCookMenu-无法导航到faces-config中的操作所定义的页面 [英] MyFaces Tomahawk JSCookMenu - failure to navigate to page defined by action in faces-config

查看:82
本文介绍了MyFaces Tomahawk JSCookMenu-无法导航到faces-config中的操作所定义的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次尝试使用JSCookMenu及其主页( http://jscook.yuanheng.org/JSCookMenu/)已经关闭了一个多星期,所以请原谅我的问题的答案.

This is my first attempt at using JSCookMenu and its homepage (http://jscook.yuanheng.org/JSCookMenu/) has been down for more than a week, so forgive me if the answer to my question should appear on there.

我有一个简单的Web应用程序,它经过精简以测试JSCookMenu将动作转发到新的JSF页面.

I have a simple web app, stripped down in order to test JSCookMenu's action forwarding to a new JSF page.

我有一个带有JSCookMenu(Apache MyFaces Tomahawk标记)的管理页面,其中包含2个菜单项:没有AL的住所"和带有AL的住所".我希望当我单击这些菜单项时,我将导航到主页"页面,该页面现在仅显示"Hello World"消息.但是,此导航没有发生.朝正确方向的推动将不胜感激:-)

I have an admin page with a JSCookMenu (Apache MyFaces Tomahawk tags) with 2 menu items, 'Home Without AL' and 'Home With AL'. I expect that when I click on these menu items that I will navigate to the 'home' page which will just display a 'Hello World' message for now. This navigation is not happening, however. A push in the right direction would be greatly appreciated :-)

这是我的faces-config,我的管理页面(使用布局页面),我的主页,我的web.xml(已映射过滤器)以及当我单击菜单项时发生的情况的描述.

Here's my faces-config, my admin page (which uses layout page), my home page, my web.xml (with filter mapped) and a description of what happens when I click on the menu item.

faces-config.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:

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:

admin.jsp:

    <jsp:forward page="admin.jsf"/>

admin.xhtml:

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:

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),该路径是从

I have tomahawk12-1.1.9.jar in my classpath (also tried tomahawk-1.1.9.jar), which I downloaded from http://myfaces.apache.org/tomahawk/download.html.

我在我的Web应用程序的根目录下有一个jscookmenu文件夹,其中包含每个主题的文件夹(每个文件夹都有theme.css和theme.js),effect.js和jscookmenu-2.0.4.zip中的JSCookMenu.js,所有这些都是我从 http://sourceforge.net/projects/jscook/files/.最新版本是2009-05-25.

I have a jscookmenu folder at the root of my webapp, containing a folder for each theme (each with theme.css and theme.js), effect.js and the JSCookMenu.js from jscookmenu-2.0.4.zip, all of which I downloaded from http://sourceforge.net/projects/jscook/files/. Latest release was 2009-05-25.

该Web应用程序已部署在本地主机上的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:所请求的资源()不可用."

The web app is deployed on Sun GlassFish Enterprise Server v2.1 on localhost.
I browse to http://localhost:8080/beachwater/admin.jsp and click on the Home menu item.
New window is opened with address bar, "http://localhost:8080/beachwater/form_j_id7_menu:A%5Dgo_home" and content, "Glassfish error page, HTTP Status 404: The requested resource () is not available."

什么都没写到服务器上.日志

Nothing gets written to the server.log

该窗口由JSCookMenu.js中的cmItemMouseUp函数打开.我的JavaScript版本错误吗?有什么想法为什么过滤器不调用faces-config中指定的操作?

The window is being opened by the cmItemMouseUp function in JSCookMenu.js. Do I have the wrong version of the javascript? Any ideas why the filter isn't invoking the action specified in faces-config?

推荐答案

事实证明,

It turns out that the 'Instructions' section on http://myfaces.apache.org/tomahawk-project/tomahawk12/tagdoc/t_jscookMenu.html is out of date. It is no longer necessary to...

  • 将包含CSS和脚本代码的jscookmenu目录添加到您的Web目录中(您可以在示例应用程序中找到它).
  • 将您要使用的主题的脚本和样式表添加到html-header中(请参见示例应用程序中的inc/header.inc)

...,因为它们现在包含在战斧缸中.因此,我从我的Web应用程序的根目录以及从layout.xhtml的开头删除了上述的jscookmenu文件夹:

... as these are now contained in the tomahawk jar. So I removed the aforementioned jscookmenu folder from the root of my webapp, as well as these from the head of 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,所以我添加了以下内容:

I also hadn't included *.jsp in my filter-mapping in web.xml, so I added as follows:

<filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
</filter-mapping>

现在,菜单正在页面上呈现.

By now, the menu was rendering on the page.

当我尝试从一页导航到另一页时,出现此错误:

When I then tried to navigate from one page to another, I got this error:

dummyForm.elements.jscook_action is undefined

,我通过将其添加到admin.jsp中来解决,如 http://forums.sun.com/thread.jspa?forumID=427&threadID=761310 :

, which I solved by adding this to admin.jsp, as suggested by http://forums.sun.com/thread.jspa?forumID=427&threadID=761310:

<input type="hidden" id="jscook_action" name="jscook_action" />

希望这对某人有帮助,因为JSCookMenu网站仍处于关闭状态,并且其他地方的帮助似乎很小.

Hope this helps someone, as the JSCookMenu website is still down and help seems to be pretty thin on the ground elsewhere.

这篇关于MyFaces Tomahawk JSCookMenu-无法导航到faces-config中的操作所定义的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆