What I'm looking for is how to setup the functionality so that the
framework uses my "click-page_en.properties file".
If a form-element named "username" yields an error I would like to have
the framework assign the value of "username_error" to the field.
Is this possible?
Regards, getagrip
getagrip wrote:
> 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