Hi,
is it possible to add custom validation error-messages to single field
objects upon validation?
Of course I can pick every single field and add a message to it by hand,
but considering dozens of fields per form this would be a very tedious job.
I need to do server-side validation and I have the form's FieldList:
List<Field> fieldlist = form.getFieldList();
for(Field field : fieldlist) {
// the field's error-property has been set before by the framework...
if(! "".equals(field.getError())) {
// Every form-element needs to have a custom error-message so here
// is my problem: I do not want to perform a huge if-else
// orgy here by checking all possible form-element-names so is there
// another way?
}
}
I guest it might be possible to have this done automatically via
messagebundles.
The docs say:
"Field classes support a hierarchy of resource bundles for displaying
validation error messages and display messages. These localized messages
can be accessed through the Field methods".
Are there any examples out there that demonstrate this behaviour?
Regards, getagrip