从 JSF 1.2 迁移到 JSF 2.0 后,每次导航时都会出现 ViewExpiredException

发布于 2024-11-10 03:01:19 字数 1378 浏览 6 评论 0原文

我正在尝试将现有的 JSF 应用程序从 JSF 1.2 迁移到 JSF 2.0。我正在使用 MyFaces 1.2.8,现在想使用 MyFaces 2.0.5。

我在使用 MyFaces 2.0.5 时遇到的情况是,最初请求的页面将正确呈现,但任何导航到其他页面的尝试都将导致 ViewExpiredException。该消息是:

无法找到视图标识符的已保存视图状态:/SomePageName.jsf(其中“SomePageName”是我要离开的页面的名称)

如果我手动键入我想要导航到的页面的友好 URL,例如 http://localhost:8080/MYAPP/ SomeOtherPage.jsf ,那么另一个页面将被正确渲染。该应用程序还识别出我已经有一个会话,并且不会尝试创建新会话。

我的应用程序仅由 JSP 文件组成,正如您对 JSF 1.2 应用程序所期望的那样。我的目的是首先让应用程序在 JSF 2.0 中运行,然后一次将每个页面重写为 Facelet。

我的一些导航规则看起来像这样:

<navigation-rule>
    <display-name>ManagePorts</displayName>
    <from-view-id>/ManagePorts.jsp</from-view-id>
    <navigation-case>
        <from-outcome>REFRESH</from-outcome>
        <to-view-id>/ManagePorts.jsp</to-view-id>
    </navigation-case>
</navigation-rule>

有些看起来像这样:(

<navigation-rule>
    <navigation-case>
        <from-outcome>MANAGE_PORT_LIST</from-outcome>
        <to-view-id>/ManagePorts.jsp</to-view-id>
    </navigation-case>
</navigation-rule>

我意识到 REFRESH 结果不是最好的做事方式,但这已经在旧的 1.2 应用程序中,我不打算删除它,直到我开始迁移工作)

谁能告诉我我可能做错了什么,导致导航像这样崩溃?

I'm attempting to migrate an existing JSF application from JSF 1.2 to JSF 2.0. I was using MyFaces 1.2.8 and want to use MyFaces 2.0.5.

What I'm experiencing with MyFaces 2.0.5 is that the initially requested page will render properly, but any attempt to navigate to another page will result in a ViewExpiredException. The message is:

No saved view state could be found for the view identifier: /SomePageName.jsf (where "SomePageName" is the name of the page that I am navigating away from)

If I manually type the Faces-friendly URL of the page I wanted to navigate to, such as http://localhost:8080/MYAPP/SomeOtherPage.jsf , then the other page will be properly rendered. The application also recognizes that I already have a session and does not try to create a new one.

My application consists exclusively of JSP files, as you would expect from a JSF 1.2 app. My intention is to first get the app working in JSF 2.0 and then rewrite each page as a Facelet one at a time.

Some of my navigation rules look like this:

<navigation-rule>
    <display-name>ManagePorts</displayName>
    <from-view-id>/ManagePorts.jsp</from-view-id>
    <navigation-case>
        <from-outcome>REFRESH</from-outcome>
        <to-view-id>/ManagePorts.jsp</to-view-id>
    </navigation-case>
</navigation-rule>

and some look like this:

<navigation-rule>
    <navigation-case>
        <from-outcome>MANAGE_PORT_LIST</from-outcome>
        <to-view-id>/ManagePorts.jsp</to-view-id>
    </navigation-case>
</navigation-rule>

(I realize that the REFRESH outcome is not the best way to do things, but that was already in the old 1.2 application and I'm not planning to remove it until I start the migration effort)

Can anyone tell me what I might be doing wrong that would cause the navigation to blow up like this?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终陌 2024-11-17 03:01:19

我怀疑这是 MyFaces 特有的,我们从 Mojarra 1.2 迁移到 2.0 时没有遇到此问题。我建议您尝试一下,尽管这只是排除其中一个或另一个,以便您最终可以向 MyFaces 男孩报告该问题。

我已经没有想法了,所以也许尝试不同的 JSF 实现是唯一合乎逻辑的选择。我只是在犹豫,因为我们正在迁移的应用程序中使用 MyFaces Tomahawk 和 Trinidad 附加组件。为了使用 Mojarra(或其他东西)尝试该应用程序,我必须删除依赖于附加组件的页面块。哦,好吧,我想我应该停止为此烦恼,去做吧! :)

Tomahawk/Trinidad 没有明确要求 MyFaces 作为 JSF 实现。这是一个(营销)神话。它们恰好来自同一供应商(Apache)。第 3 方 JSF 组件库只需要 JSF API。 impl(Mojarra、MyFaces 等)确实不重要。

I suspect that this is MyFaces specific, we didn't have this problem when migrating from Mojarra 1.2 to 2.0. I would suggest to try it instead, even though it's only to exclude the one and other so that you can eventually report the issue to MyFaces boys.

I'm running out of ideas, so maybe trying a different JSF implementation is the only logical alternative. I'm only hesitating because we are using the MyFaces Tomahawk and Trinidad add-ons in the application that I'm migrating. In order to try the app using Mojarra (or something else) I will have to remove chunks of the pages that depend on the add-ons. Oh well, I guess I should stop fretting about it and just do it! :)

Tomahawk/Trinidad doesn't explicitly require MyFaces as JSF impl. This is a (marketing) myth. They just happens to be from the same vendor (Apache). 3rd party JSF component libraries just require a JSF API. The impl (Mojarra, MyFaces, etc) really shouldn't matter.

因为看清所以看轻 2024-11-17 03:01:19

此问题已修复:

https://issues.apache.org/jira/browse/MYFACES -3101

注意 MyFaces 2.0.7 和 2.1.1 已修复。

This issue was fixed on:

https://issues.apache.org/jira/browse/MYFACES-3101

Note MyFaces 2.0.7 and 2.1.1 has the fix.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文