Hi,
I have a form with two required fields for example: "age" and "dateOfBirth",
all of them are required, but if they are in special group, then only one of
them is required.
In my custom class CustomFieldBlocks.java which  implements
PropertyOverrides, I should return field validator for the field. 
The main question is: How to implement custom validator with only one
required field from set of fields. 
For example : 
private FieldValidator getValidator(Field field) {
        FieldValidator contextValidator = context.getValidator(field);
        PropertyModel propertyModel =
beanModel.getById(context.getPropertyId());
        String propertyLabel = propertyModel.getPropertyName();
        if (propertyModel != null &&
mandatoryCustomFields.contains(propertyLabel)) {
                 List<Field> fields = new ArrayList<Field>();
//                 here I want to get all required fields for pass
                 for (String fieldLabel : mandatoryCustomFields){
                      Field field = ?????
                      fields.add(field);
                 }
                GroupValidator groupValidator = new GroupValidator(fields,
"groupValidator");
                return new
CompositeFieldValidator(Arrays.asList(groupValidator, contextValidator));
        } else {
                FieldValidator required =
fieldValidatorSource.createValidator(field, "required", null);
                return new CompositeFieldValidator(Arrays.asList(required,
contextValidator));
       }
       return contextValidator;
    }



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/group-of-requred-fields-tp5720512.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to