使用 h:commandButton 进行 Ajax 更新和提交
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15548707/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ajax update and submission using h:commandButton
提问by Wizard Sultan
How to update a div and do partial submission using <h:commandButton>, I have previously used <p:commandButton>to do partial submission by setting the ajax attribute to true and the update attribute to :statusBlock, where the id of the <h:panelGroup>is statusBlock. I am having some designing issues with <p:commandButton>so I cannot use it so I have to use <h:commandButton>.
如何更新div并使用 进行部分提交<h:commandButton>,我以前曾经<p:commandButton>通过将ajax属性设置为true并将更新属性设置为:statusBlock来进行部分提交,其中id<h:panelGroup>是statusBlock。我有一些设计问题,<p:commandButton>所以我无法使用它,所以我必须使用<h:commandButton>.
回答by BalusC
This is to be done by nesting a <f:ajax>in it.
这是通过<f:ajax>在其中嵌套 a 来完成的。
In effects,
在效果上,
<p:commandButton ... process="@form" update=":statusBlock" />
does exactly the same as
完全一样
<h:commandButton ...>
<f:ajax execute="@form" render=":statusBlock" />
</h:commandButton>
Note that the subtle difference with the PrimeFaces equivalent is that PrimeFaces defaults to @formin the process/execute, while the <f:ajax>one defaults to @this, so you might need to explicitly specify execute="@form"over all place where you didn't specify the processattribute in the PrimeFaces component.
请注意,与 PrimeFaces 等效项的细微差别在于 PrimeFaces@form在 process/execute 中<f:ajax>默认为@this,而默认为,因此您可能需要execute="@form"在所有未process在 PrimeFaces 组件中指定属性的地方显式指定。
See also:
也可以看看:
回答by planetjones
You can just use the standard components alongside f:ajax e.g.
你可以在 f:ajax 旁边使用标准组件,例如
<h:form id="myForm">
<h:commandButton value="Push Me">
<f:ajax execute="myForm" render="statusBlock" />
</h:commandButton>
<h:panelGroup id="statusBlock">
</h:panelGroup>
</h:form>

