My problem is I have more than one Primefaces
's commandButton
in an xhtml page.My required messages and validators work for each of them. This is not what I desire. I want that the required messages and validators should work only when I clicked the commandbutton with the id is "sendform
"
<p:growl id="growl" life="6000" />
<p:inputText id="fullName"
value="#{messageBean.fullName}"
required="true"
requiredMessage="You need to enter your full name to apply this form."
styleClass="contacttext"/>
<p:inputText id="email"
value="#{messageBean.email}"
required="true"
requiredMessage="You need to enter your email to apply this form."
validatorMessage="Invalid e-mail format">
<f:validateRegex pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />
</p:inputText>
<p:commandButton id="sendform"
value="#{msg['sendUs']}"
actionListener="#{messageBean.sendMessage}"
update="growl fullName email textarea"
styleClass="sendus"/>
<p:commandButton id ="otherStuff"
value="otherStuff"
actionlistener="#{someBean.someWork}" />
<p:commandButton id ="anotherStuff"
value="anotherStuff"
actionlistener="#{anotherBean.anotherWork}" />
How can I fix it up to run required messages only this commandbutton?
<p:commandButton id="sendform"
value="#{msg['sendUs']}"
actionListener="#{messageBean.sendMessage}"
update="growl fullName email textarea"
styleClass="sendus"/>