hi, I've a form where the user can add fields dynamically by clicking an "Add" button , and these are stored as a Map in the model , like :
dynamicfields[0].firstname dynamicfields[0].lastname dynamicfields[1].firstname etc. The first instance (i.e dynamicfields[0]..) will always be present and there are some validation rules associated with it. I need to replicate the same for every field that's added dynamically. I was thinking of defining the rules for this in validation XML , cloning these rules for as many fields are present in the submitted form, adding these cloned validators dynamically to the list, and then call validate() from the Action - default validation skipped using @SkipValidation. Looking at the validationmanager class, it seems the getValidators() gives a copy of the validators and there's no way to setValidators() ... Please suggest if this route is worth pursuing, or i must use a custom validator for this scenario. The only thing i dont like about the custom validator is that i'll have to call all the default validators corresponding to each rule manually, whereas XML declaration seems cleaner. Thanks, Joseph