/** * Checks the validity of the Form and all of its fields. * * @see Validatable#validate() */ @Override public void validate() throws InvalidValueException { super.validate(); for (final Object id : propertyIds) { fields.get(id).validate(); } }
/** * Checks the validity of the bound fields. * <p> * Call the {@link Field#validate()} for the fields to get the individual * error messages. * * @return true if all bound fields are valid, false otherwise. */ public boolean isValid() { try { for (Field<?> field : getFields()) { field.validate(); } return true; } catch (InvalidValueException e) { return false; } }
@Override public void validate() throws Validator.InvalidValueException { super.validate(); Collection v = getValue(); if(v != null) { for (Object o : v) { for (Field f : getFieldGroupFor((ET) o).getFields()) { f.validate(); } } } }
try { for (Field<?> field : getFields()) { field.validate();
/** * Validates the given field and sets the component error accordingly. * Please note, that the provided field must implement {@link Field} and must be a sub class of {@link AbstractComponent}. * * @param field The field to validate (must be a sub class of {@link AbstractComponent}). * @param swallowValidationExceptions Indicates if an InvalidValueException is swallowed and not propagated. * If false the first occurring InvalidValueException is thrown. * @throws Validator.InvalidValueException If the field is not valid (see {@link Validator#validate(Object)}. */ public static void validateField(Field<?> field, boolean swallowValidationExceptions) throws Validator.InvalidValueException { if (field instanceof AbstractComponent && field.isEnabled()) { try { field.validate(); ((AbstractComponent) field).setComponentError(null); } catch (Validator.InvalidValueException ex) { // Some fields unify exceptions, we have to consider this if (ex.getMessage() == null) { ex = ex.getCauses()[0]; } // set error message ((AbstractComponent) field).setComponentError(new UserError(ex.getMessage())); if (!swallowValidationExceptions) { throw ex; } } } }