Tomahawk JSCookMenu 升级到 JSF2 后不会触发任何操作

发布于 2024-12-29 05:52:34 字数 2925 浏览 1 评论 0原文

我刚刚将一些中型 Web 应用程序从 JSF 1.2/MyFaces 迁移到 JSF 2.0/Mojarra。除了我实现的一些自定义组件之外,一切似乎都可以工作,除了 Tomahawk 的 JSCookMenu (是的,我有 Tomahawk,它是 Apache 的一个库,并且仍然想使用 Mojarra - 但我知道不应该任何大问题)。我已将 myfaces-api.jar 和 myfaces-impl.jar 替换为相应的 jsf-api.jar 和 jsf-impl.jar,并从 web.xml 中取出尽可能多的 MyFaces 参数和过滤器(有些参数和过滤器需要留下来是因为我仍然使用战斧)。我还将 JSF2 的 Tomahawk 升级到 1.1.11。

应用程序的 JSCookMenu 渲染得很好,但单击菜单项时不会触发任何操作。我有一些 t:navigationMenuItem,其 action 属性绑定到 faces-config.xml 中的结果,该结果应该加载新的视图 id,还有一些 t:navigationMenuItem,其 actionListener 属性绑定到 bean 方法(Logout 菜单项,例如例子)。它们都不起作用,我的 bean 中的 actionListener 代码甚至没有被调用。

我什至不知道如何调查这个问题,有人知道如何解决这个问题吗?我希望 web.xml 中的内容可以有所帮助。

导航案例在 faces-config.xml 中正确编写,它们曾经在 JSF 1.2/MyFaces 上工作,在迁移到 Mojarra 之前也在 JSF 2/MyFaces 上工作。

这是我的 web.xml 文件的相关部分:

<servlet>
    <servlet-name>faces</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>faces</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>com.sun.faces.allowTextChildren</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.FACELETS_RESOURCE_RESOLVER</param-name>
    <param-value>com.avalanche.jsf.MyResourceResolver</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
</context-param>
<context-param>
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>facelets.RECREATE_VALUE_EXPRESSION_ON_BUILD_BEFORE_RESTORE</param-name>
    <param-value>false</param-value>
</context-param>

<filter>
    <filter-name>facesExtensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
        <param-name>uploadMaxFileSize</param-name>
        <param-value>1g</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>facesExtensionsFilter</filter-name>
    <servlet-name>faces</servlet-name>
</filter-mapping>
<filter-mapping>
    <filter-name>facesExtensionsFilter</filter-name>
    <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>

I've just migrated some medium-size web application from JSF 1.2/MyFaces to JSF 2.0/Mojarra. Apart from some custom components that I've implemented, everything seems to work, except for the JSCookMenu from Tomahawk (yes, I have Tomahawk which is a library from Apache, and still want to use Mojarra - but I understood there shouldn't be any big problem). I've replaced the myfaces-api.jar and myfaces-impl.jar with the corresponding jsf-api.jar and jsf-impl.jar, and took out from web.xml as many MyFaces parameters and filters as possible (some needed to remain because I still use Tomahawk). I have also upgraded Tomahawk to 1.1.11 for JSF2.

The application's JSCookMenu renders just fine, but doesn't trigger any action when clicking the menu items. I have some t:navigationMenuItem whose action attribute is bound to an outcome in faces-config.xml which should load a new view id, and yet some t:navigationMenuItem whose actionListener attribute is bound to a bean method (the Logout menu item, for example). Neither of them works, the actionListener code from my bean is not even called.

I'm not even sure how to investigate this, did anybody have a clue as to how can this be solved? I'm hoping something in web.xml can be of help.

The navigation cases are written correctly in the faces-config.xml, they used to work on JSF 1.2/MyFaces and also on JSF 2/MyFaces prior to the migration to Mojarra.

This is the relevant part of my web.xml file:

<servlet>
    <servlet-name>faces</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>faces</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>com.sun.faces.allowTextChildren</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.FACELETS_RESOURCE_RESOLVER</param-name>
    <param-value>com.avalanche.jsf.MyResourceResolver</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
</context-param>
<context-param>
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>facelets.RECREATE_VALUE_EXPRESSION_ON_BUILD_BEFORE_RESTORE</param-name>
    <param-value>false</param-value>
</context-param>

<filter>
    <filter-name>facesExtensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
        <param-name>uploadMaxFileSize</param-name>
        <param-value>1g</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>facesExtensionsFilter</filter-name>
    <servlet-name>faces</servlet-name>
</filter-mapping>
<filter-mapping>
    <filter-name>facesExtensionsFilter</filter-name>
    <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文