예제 #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");
     }
   }
 }
 @Override
 public boolean validateForm() {
   boolean firstErrorFound = false;
   Set<PhysicalAttributeConfirmActualsFieldSetComponent> formFieldHeaders = headers.keySet();
   for (PhysicalAttributeConfirmActualsFieldSetComponent fieldSet : formFieldHeaders) {
     headers.get(fieldSet).removeStyleName("conx-form-header-error");
   }
   Set<Field> formFields = fields.keySet();
   for (Field field : formFields) {
     VaadinCollapsiblePhysicalAttributeConfirmActualsFormSectionHeader formFieldHeader =
         getFieldHeader(field);
     if (formFieldHeader != null) {
       try {
         field.validate();
         field.removeStyleName("conx-form-field-error");
       } catch (InvalidValueException e) {
         field.addStyleName("conx-form-field-error");
         formFieldHeader.addStyleName("conx-form-header-error");
         if (!firstErrorFound) {
           this.alertPanel.setMessage(e.getMessage());
           this.alertPanel.setVisible(true);
           firstErrorFound = true;
         }
       }
     }
   }
   if (firstErrorFound) {
     //			this.verifyButton.setEnabled(false);
     return false;
   } else {
     this.alertPanel.setVisible(false);
     //			this.verifyButton.setEnabled(false);
     //			this.saveButton.setEnabled(true);
     this.alertPanel.setAlertType(AlertType.SUCCESS);
     this.alertPanel.setMessage(this.header.getTitle() + " is valid.");
     this.alertPanel.setVisible(true);
     return true;
   }
 }