Forms 在JSF中更新多个表单
你好,我有这样的东西:Forms 在JSF中更新多个表单,forms,jsf,Forms,Jsf,你好,我有这样的东西: <h:form id="firstForm"> here i have some input fields </h:form> <h:form id="secondForm"> here i have some input fields </h:form> <h:form id="thirdForm"> <p:commandButton id="completeOne" type="button"
<h:form id="firstForm">
here i have some input fields
</h:form>
<h:form id="secondForm">
here i have some input fields
</h:form>
<h:form id="thirdForm">
<p:commandButton id="completeOne" type="button"
value="Complete">
</p:commandButton>
</h:form>
这里有一些输入字段
这里有一些输入字段
我的问题是,通过按“完成”按钮如何更新表单:firstForm和secondForm来指示哪些组件应该通过AJAX请求更新(即接收新的HTML),有一个恰当命名的属性
update
:-)
在您的情况下,如果希望通过命令按钮更新firstForm
和secondForm
,请使用:
<p:commandButton id="completeOne"
type="button" value="Complete" update="firstForm secondForm">
</p:commandButton>
PrimeFaces文档中对此进行了描述:
AJAX与非AJAX
CommandButton具有内置的ajax功能,ajax提交是
默认情况下启用,并使用ajax
属性进行配置。什么时候
ajax属性设置为false,表单以常规的完整格式提交
页面刷新
update
属性用于部分更新其他
接收到ajax响应后的组件。更新
属性采用逗号或空格分隔的JSF组件列表
要更新的ID。基本上是任何JSF组件,而不仅仅是PrimeFaces
组件应该使用Ajax响应进行更新
update
属性的默认值是@form
,这意味着只更新包含组件的表单。在您的情况下,这将是第三种形式,
这还不够
注: 普通JSF(即没有PrimeFaces)具有与的类似属性,该属性指示要更新的组件。但是,对于
f:ajax
,它被称为render
,而不是update
。很容易混淆这两者,特别是当您混合使用普通JSF和PrimeFaces标记时