I have a form with inputs to fill customer data with name surname and id
name surname lastName
[ ] [ ] [ ]
id other fields
[ ] [ ]
Inputs are defined as usually:
<p:inputText id="name" required="true" value="#{contactForm.name}" label="Name" styleClass="form-control">
<p:clientValidator/>
</p:inputText>
<p:message for="name" />
When id field is filled I make an ajax call to see if data corresponds with a customer in this way:
<p:outputLabel for="ID" value="ID" />
<p:inputText id="ID" required="true" value="ID" label="ID" styleClass="form-control">
<p:ajax
event="change"
listener="#contactController.identifyCustomer(contactForm)}"
process="@this name,surname1,surname2"
update="newCustomerPanel"
/>
<p:clientValidator/>
</p:inputText>
<p:message for="dni" />
In the happy case user introduces all data in a correct way this works nice.
My problem comes when the ajax call is executed with no data retrieved and the user needs to change some of the inputs, if the event needs to be launched user must pass through id input field change data and return which is not the way.
Now is working with workaround: inserting an ajax call to all fields involved. When any input launches event, in server side I check if all data is complete and has changed to call the service that retrieves customer data...
But honestly, this is an ugly solution that wastes lot of calls and does not give a good user experience.
So I was wondering, is there a way group all fields and assign the ajax call and event="change"
to this group?