Let me explain the scenario, assume that I have an class Project which contains a list of people, and you can search the a person and write his tasks on the project.
Alright, so, I have a button to add people which leads to a modal, with the fields to fill and a search button... This search button, leads to another modal which is a simple person search, you type the name, select one from the list, the search modal closes and the name goes to an outputText on the previous modal.
The thing is, how do I validate this field? I mean, the other fields I can just put required=true, set a requiredMessage and a p:message.
Everything works fine, the values, the buttons, all works, except for the validation of this field. To give a little more clearance, this is what I need:
This is my button, opens the modal, only rendered if a condition is required, all good.
<p:commandButton icon="ui-icon-search" validateClient="true" type="button" onclick="PF('modalSearchPerson').show();" rendered="#{projectMB.projectParticipant.type == 'STUDENT'}"/>
And this is the text which displays the name of the participant, which is updated by the modalSearchPerson.
<h:outputText id="personName" title="Participant" value="#{projectMB.projectParticipant.person.name}"/>
What I wanted, is something as simple as required="true" requiredMessage="You must choose a person.", on the h:outputText field.
I hope I made it clear, Thanks.
edit: It must block the submission, if I only update the :growl with error messages set on the MB, the modal will close, and I dont want that.
The button I use to not close the modal has:
oncomplete="if (args && !args.validationFailed) PF('modalAddParticipant').hide();"