单击 h:commandButton 生成的提交按钮会触发加载吗?
jsf 页面包含一个带有 commandButton
元素的表单,例如 submit
按钮将触发一个bean,然后该bean会将更多数据发送回同一个jsf页面。
问题:提交后,jsf页面是否再次完全加载?或者只是包含新检索的数据的部分重新加载而其他部分没有再次加载?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,JSF将完全重新加载页面。在提交
commandbutton
时,可以通过查看浏览器网络开发人员工具来测试这一点。如果您打算仅渲染页面的一部分 - 例如输出结果的标签 - 您可以使用Ajax来执行此操作。例如,如果您的
commandbutton
以表单为fand,通过在
commandbutton
标签中添加,您可以指定仅服务器的内容是由服务器处理的,并且只有标签使用ID“结果”。有关更多信息,请查看JSF中AJAX的本指南: https:> https:> https:> https: //www.beyondjava.net/a-comprehens-guide-to-jsf-ajax
您会看到作者在没有AJAX的情况下显示了整个页面加载。
另外,这里是
< f:ajax>
的官方文档: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 addingwithin 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