public boolean validate() { try { this.binder_esoporte.commit(); this.mensajes.add(new BarMessage("Formulario", Messages.SUCCESS_MESSAGE, "success")); return true; } catch (CommitException e) { try { this.txt_nombre_esoporte.validate(); } catch (EmptyValueException ex) { this.mensajes.add(new BarMessage(txt_nombre_esoporte.getCaption(), Messages.EMPTY_MESSAGE)); } catch (InvalidValueException ex) { this.mensajes.add(new BarMessage(txt_nombre_esoporte.getCaption(), ex.getMessage())); } return false; } }
@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; } }