Exemplo n.º 1
0
 /**
  * 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");
     }
   }
 }
Exemplo n.º 2
0
 /**
  * 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);
     }
   }
 }
Exemplo n.º 3
0
 /**
  * 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);
     }
   }
 }