JSF 页面在转发到自身后丢失值

发布于 2024-12-14 19:51:46 字数 61 浏览 4 评论 0原文

每当我让 JSF 页面对其自身执行转发时,它都会丢失所有输入的表单值。它是否有可能以某种方式保留这些价值观?

Whenever I let a JSF page perform a forward to itself, it loses all it's entered form values. Is it possible for it to somehow retain this values?

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

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

发布评论

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

评论(2

迷离° 2024-12-21 19:51:46

当您根本不向服务器提交表单的输入值时,就会发生这种情况。例如,当您使用输出链接而不是命令链接时,或者当您在命令链接/按钮上使用 immediate="true" 时,或者当命令链接/按钮为以与输入不同的形式放置,等等。

这些值不会保留在下一个视图中,这是正常行为。那么,bean 的范围实际上并不重要。如果您想在下一个视图中保留它们,您还必须同时提交表单的输入值。即使 bean 是请求范围的并且您正在执行简单的转发(而不是重定向),输入值也将被保留。

That will happen when you're not submitting the form's input values to the server at all. For example, when you're using an output link instead of a command link, or when you're using immediate="true" on the command link/button, or when the command link/button is been placed in a different form than the inputs, etcetera.

It's normal behaviour that those values will not be retained in the next view then. The scope of the bean really doesn't matter then. If you want to retain them in the next view, you've got to submit the form's input values along as well. Even when the bean is request scoped and you're doing a simple forward (not a redirect), then the input values will be retained.

因为看清所以看轻 2024-12-21 19:51:46

你应该看看你想要保留的值的范围?视图范围值仅在页面的生命周期内可用,请求范围将在新页面上被忽略,因此您必须更多地了解您的应用程序流程。

You should look at the scope of the values that you want to retain? view scoped values will only be available for the lifetime of the page, request scope, will be disregarded on a new page forward, so you have to look a bit more into your application flow.

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