我在Glassfish上使用带有JSF-2的Primefaces,试图交叉验证表单。以下是场景:
<h:form id="form1">
<p:messages id="msgs" showDetail="false" autoUpdate="true" closable="true" />
some input fields with validation
</h:form>
<h:form id="form_upload">
some upload fields that dont trigger validations
</h:form>
<h:form id="buts">
<p:commandButton id="save" value="Save" action="#{bean.save}"
update=":form1 :form1:msgs" process=":form1">
</h:form>
我想用按钮保存来触发form1上的验证,这是可能的吗?
发布于 2012-12-29 02:18:13
使用属性process
并指定要在服务器上处理的每个组件:
<p:commandButton id="save" value="Save" action="#{bean.save}"
process=":form1 :form_upload" update=":form1" />
别忘了在:form1
中的某个地方放一个p:messages
,否则你也想更新它。
阅读有关AJAX on JSF here的更多信息。
发布于 2015-03-02 18:58:33
您可以使用PrimeFaces的<p:remoteCommand>
<h:form id="form1">
some input fields with validation
<p:remoteCommand name="rc" update="@form" action="#{bean.save}" />
</h:form>
远程调用示例:
<h:form id="buts">
<p:commandButton value="Save" type="button" onclick="rc()" />
</h>
https://stackoverflow.com/questions/14073734
复制相似问题