JSF/Mojarra“闪光范围”问题

发布于 2024-11-16 05:53:09 字数 904 浏览 3 评论 0原文

我有一个在 Mojarra 2.1.1 / Glassfish 3.1 上运行的应用程序,现已增长到 150,000+ 代码行。该应用程序广泛使用 ajax 和 ViewScoped 托管 bean 以及 页面重定向获取模式(即 faces-redirect=true)。

一直让我烦恼的一件事是明显缺乏通过的轻松性 参数从页面到页面,从 bean 到 bean(每个页面都有它自己的支持 bean)。

我无法让闪光灯工作。我通常需要访问我拥有的数据 在下一页的preRenderView事件监听器中写入flash。这不 可靠地工作,特别是在应用程序重新部署之后。

我已经阅读了 CDI 并花了几天时间尝试从 JSF 托管 bean 迁移 到 CDI bean,但无法让它工作。貌似兼容性问题很多 位于 Seam 3 和 Glassfish 3.1 之间。我将 Weld 升级到 1.1.1 但这没有帮助。从 我的观点是目前还行不通。例如,当我说不起作用时 我有一个页面试图将 h:inputText 转换为支持 bean 中的字符串,但这并没有 工作,很简单的事情。

由于我遇到的 CDI 问题,我无法使用接缝面 @RenderScoped 一个非常简单的测试应用程序(即使在 g/f 3.1 上)正是我想要的,但不是在 复杂的主要应用程序。

目前我能找到的唯一可靠的机制是 URL 参数,它是 安全噩梦。尽管已尽一切努力确保对数据的访问 经过正确的验证,总会有丢失某些东西的变化,并且看到 ...xhtml?id=51031 或浏览器中的任何内容对于某些人来说太过难以抗拒 尝试其他id。我写了一个混淆转换器来避免明文,但不 对名称/值对使用有意义的名称,但这并没有触及问题的根源 问题。

我只是想知道我是否在这里遗漏了一些东西,其他人都有可行的解决方案吗 对于这个问题,即使是在 glassfish 上?我是不是担心太多了,应该坚持使用 URL 参数?还有其他建议吗?

谢谢。

I've got an app running on Mojarra 2.1.1 / Glassfish 3.1 which has now grown to 150,000+
lines of code. The app uses ajax extensively with ViewScoped managed beans and the
page-redirect-get pattern (i.e. faces-redirect=true).

One thing that is continually annoying me is the apparent lack of ease of passing
parameters from page to page, and bean to bean (every page has it's own backing bean).

I've not been able to get the flash working. I typically need to access the data I've
written to the flash in the preRenderView event listener of the next page. This doesn't
work reliably, particularly after an application redeployment.

I've read up on CDI and have spent a few days trying to migrate from JSF managed beans
to CDI beans, but can't get it to work. There seems to be a lot of compatibility issues
between Seam 3 and Glassfish 3.1. I upgraded Weld to 1.1.1 but this doesn't help. From
my perspective it just doesn't work at the moment. When I say doesn't work, for example
I have a page trying to h:inputText into a String in the backing bean and this doesn't
work, really simple stuff.

Because of the CDI problems I'm having I can't use seam-faces @RenderScoped which in
a very simple test application (even on g/f 3.1) does just what I want, but not in the
complex main application.

The only reliable mechanism I can find to use at present is URL parameters which are a
security nightmare. Even though every effort is made to ensure that access to data is
properly authenticated there's always the change of missing something, and seeing
...xhtml?id=51031 or whatever in the browser is too much for some people to resist
trying other ids. I've written an obfuscation converter to avoid clear text and don't
use meaningful names for the name/value pairs, but this doesn't get to the root of the
problem.

I just wondered if I was missing something here, has everyone else got a working solution
to this problem, even on glassfish? Am I worrying too much and should stick with URL
params? Any other suggestions?

Thanks.

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

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

发布评论

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

评论(2

灼疼热情 2024-11-23 05:53:09

我也看到了同样的情况。在我尝试的时候,Seam3 有很多 bug,而且很难将它部署到不同的服务器上。我切换到 MyFaces CODI,它从一开始就没有任何问题。对于您的情况,您应该看看@ViewAccessScoped。您可以摆脱所有这些烦人的解决方法。

I saw the same. At the time I tried it Seam3 was very buggy and it's very hard to get it deployed to different servers. I switched to MyFaces CODI which worked without any problems from the very beginning. In your case you should have a look at @ViewAccessScoped. You can get rid of all those annoying workarounds.

夜深人未静 2024-11-23 05:53:09

声明您想要设置或传递到下一个视图的参数,

<f:metadata>
    <f:viewParam name="foo" value="#{bean.foo}" />
</f:metadata>

这在 GET 的更新模型值阶段基本上是 bean.setFoo(request.getParameter("foo"))要求。

如果您在导航结果中添加 includeViewParams=true 参数,则当前视图的 声明将传递到下一个视图看法。

public String doSomething() {
    // ...
    return "next?faces-redirect=true&includeViewParams=true";
}

(注意:& 很重要!& 将不起作用,因为它不是 XML 有效的)

下一个视图应该具有相同的 来让它们在 bean 中设置。等等。

Declare the parameters which you'd like to set or pass through to the next view in a

<f:metadata>
    <f:viewParam name="foo" value="#{bean.foo}" />
</f:metadata>

This does basically bean.setFoo(request.getParameter("foo")) during update model values phase of the GET request.

If you add includeViewParams=true parameter to the navigation outcome, then the ones which are declared as <f:viewParam> of the current view will be passed through to the next view.

public String doSomething() {
    // ...
    return "next?faces-redirect=true&includeViewParams=true";
}

(note: the & is important! the & won't work as it's not XML-valid)

The next view should have the same <f:viewParam> to get them to set in the bean. And so on.

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