/** * Invokes the validation of the current field component. Adds the error style on validation * exception. */ public void validate() { try { if (fieldComponent instanceof Field) { ((Field) fieldComponent).validate(); } else if (fieldComponent instanceof FilterContainer) { ((FilterContainer) fieldComponent).validate(); } } catch (InvalidValueException e) { if (fieldComponent instanceof Field) { ((Field) fieldComponent).addStyleName("error"); ((Field) fieldComponent).removeStyleName("error"); } else if (fieldComponent instanceof FilterContainer) { ((FilterContainer) fieldComponent).addStyleName("error"); ((FilterContainer) fieldComponent).removeStyleName("error"); } } }
/** * Adds a validator to the current field component. * * @param validator A Vaadin validator */ public void addValidator(Validator validator) { if (fieldComponent != null) { if (fieldComponent instanceof Field) { ((Field) fieldComponent).addValidator(validator); } else if (fieldComponent instanceof FilterContainer) { ((FilterContainer) fieldComponent).addValidator(validator); } } }
/** * Sets the value of the current field component. * * @param value The value to set */ public void setValue(Object value) { if (fieldComponent != null) { if (fieldComponent instanceof Field) { Field field = ((Field) fieldComponent); field.setValue(value); if (field instanceof Select) { ((Select) fieldComponent).select(value); } } else if (fieldComponent instanceof FilterContainer) { ((FilterContainer) fieldComponent).setValue(value); } } }