Reputation: 227
I'm using Primefaces with JSF-2 on Glassfish, trying to cross validate a form. Here's the scenario:
<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>
I would like button save to trigger validations on form1, is that possible?
Upvotes: 2
Views: 3667
Reputation: 535
You can use PrimeFaces' <p:remoteCommand>
<h:form id="form1">
some input fields with validation
<p:remoteCommand name="rc" update="@form" action="#{bean.save}" />
</h:form>
sample remote call:
<h:form id="buts">
<p:commandButton value="Save" type="button" onclick="rc()" />
</h>
Upvotes: 0
Reputation: 23806
Use the attribute process
and specify each components you want to be processed on the server:
<p:commandButton id="save" value="Save" action="#{bean.save}"
process=":form1 :form_upload" update=":form1" />
Don't forget to put a p:messages
somewhere in :form1
, else you want to update it too.
Read more about AJAX on JSF here.
Upvotes: 1