I have a sample CRUD application, The application used is a Wine Cellar app. You can search for wines, add a wine to your cellar, update and delete wines. I got it from RESTful services with jQuery and Java using JAX-RS and Jersey.
I modified the Wine class to include validation constraints.
@NotNull(message='Name must have a value')
private String name;
@NotNull(message='Grapes must have a value')
private String grapes;
If the user creates/updates, a wine the errors will be thrown if the name and grape fields are empty. All my validation messages are returned to the browser in json format.
public Wine create(Wine wine) {...}
public Wine update(Wine wine) {...}
If only one error is thrown, I want to display the correct message to the user and also highlight the field.
How do I get the empty field(name or id) that triggered the error as well as the correct validation message?