group of requred fields
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)) { ListField fields = new ArrayListField(); // 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
Re: group of requred fields
I have groups of fields with only one required field in the same group (any but only one field from such group must be specified) It is all i need in the BeanEditor where amount of fields vary on some conditions. -- View this message in context: http://tapestry.1045711.n5.nabble.com/group-of-requred-fields-tp5720512p5720516.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
Re: group of requred fields
Yes, and if your read the javadoc for FieldValidator it says Responsible for validation of a single field. http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/FieldValidator.html Since you need to validate a group of fields, you will need to use the form's validate event. eg onValidateFromMyForm() where MyForm is the id of your form. -- View this message in context: http://tapestry.1045711.n5.nabble.com/group-of-requred-fields-tp5720512p5720517.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
Re: group of requred fields
Here's an example http://jumpstart.doublenegative.com.au/jumpstart/examples/input/morevalidation -- View this message in context: http://tapestry.1045711.n5.nabble.com/group-of-requred-fields-tp5720512p5720518.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