单击 h:commandButton 生成的提交按钮会触发加载吗?

发布于 2025-01-20 01:29:09 字数 260 浏览 4 评论 0 原文

jsf 页面包含一个带有 commandButton 元素的表单,例如 。这个submit按钮将触发一个bean,然后该bean会将更多数据发送回同一个jsf页面。

问题:提交后,jsf页面是否再次完全加载?或者只是包含新检索的数据的部分重新加载而其他部分没有再次加载?

A jsf page contains a form with a commandButton element like <h:commandButton action="#{bean.search}". This submit button will trigger a bean, which then will send more data back to this same jsf page.

Question: after the submit, is the jsf page fully loaded again? or is just the part containing the newly retrieved data reload and other parts are not loaded again?

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

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

发布评论

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

评论(1

指尖上的星空 2025-01-27 01:29:09

默认情况下,JSF将完全重新加载页面。在提交 commandbutton 时,可以通过查看浏览器网络开发人员工具来测试这一点。如果您打算仅渲染页面的一部分 - 例如输出结果的标签 - 您可以使用Ajax来执行此操作。

例如,如果您的 commandbutton 以表单为fand,通过

<f:ajax execute="@form" render="@form:result"  />

commandbutton 标签中添加,您可以指定仅服务器的内容是由服务器处理的,并且只有标签使用ID“结果”。

有关更多信息,请查看JSF中AJAX的本指南: https:> https:> https:> https: //www.beyondjava.net/a-comprehens-guide-to-jsf-ajax

您会看到作者在没有AJAX的情况下显示了整个页面加载。

另外,这里是&lt; f:ajax&gt; 的官方文档:
https://jakarta.ee.ee.ee/specifications/pecifications/faces/faces/faces/faces/2.3/2.3/2.3/vdldloc/ f/ajax.html

By default JSF will fully reload the page. This can be tested by looking at the browser network developer tools while submitting the commandButton. If you intend to only render a part of the page - e.g. a label that outputs the result - you can do that by using AJAX.

For example if your commandButton is in a form, by adding

<f:ajax execute="@form" render="@form:result"  />

within your commandButton tag, you can specify that only the contents of the form are processed by the server and only the label with the ID 'result' is rendered.

For further information take a look at this guide for AJAX in JSF: https://www.beyondjava.net/a-comprehensive-guide-to-jsf-ajax

You will see that the author shows the full page loading without AJAX.

Alternatively here is the official documentation for <f:ajax>:
https://jakarta.ee/specifications/faces/2.3/vdldoc/f/ajax.html

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