Hello all,

I have an issue when I validate a property of a Collection of object.
I don't want any error validation when the collection is empty, but if one 
line has been added,
some properties are mandatory.

Here is an example:

@ValidateNestedProperties ({
  @Validate(field = "regulationName", required=true, on = { "save" }),
  @Validate(...)
})
private List<Regulation> regulations;


When no "regulation" is submitted inside the form, there should not be any 
error message.

To perform what I want, I need to have a huge unnecessary and unproductive 
validation method instead of the usual @validation annotation:


@ValidationMethod(on={"save"})
public void validation(ValidationErrors errors) {
  int index=0;
  if(regulations!=null){
    for(Regulation regulation : regulations){
      if(regulation!=null && regulation.getRegulationName()==null){
         errors.add("regulations["+ index +"].regulationName",
             new LocalizableError ("validation.required.valueNotPresent"));
      }
      if(other basic validation) {....}
      index++;

    }
  }
}


Is there some way to avoid this ?

thanks.
Lionel 




------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to