Package eu.maydu.gwt.validation.client

Examples of eu.maydu.gwt.validation.client.ValidationException


  private void throwValidationException(String propertyName, String message) throws ValidationException {
    InvalidValueSerializable iv = new InvalidValueSerializable();
    iv.setMessage(message);
    iv.setPropertyName(propertyName);
    if(this.throwOnFirstError) {
      ValidationException ex = new ValidationException();
      ex.getInvalidValues().add(iv);
      throw ex;
    }else {
      invalidPool.add(iv);
    }
  }
View Full Code Here


  public ServerValidation validate() throws ValidationException {
    if(this.throwOnFirstError)
      return this;
   
    if(!invalidPool.isEmpty()) {
      ValidationException ex = new ValidationException();
      for(InvalidValueSerializable iv : invalidPool)
        ex.getInvalidValues().add(iv);
      throw ex;
    }
    return this;
  }
View Full Code Here

      }
    }
   
    iv.setMessage(msgKey);
    iv.setPropertyName(propertyName);
    ValidationException ex = new ValidationException();
    ex.getInvalidValues().add(iv);
    throw ex;
  }
View Full Code Here

      return createValidationException((InvalidStateException)exception);
    }else if(exception instanceof PropertyValueException) {
      return createValidationException((PropertyValueException)exception);
    }
   
    return new ValidationException("Unknown");
   
  }
View Full Code Here

      m = m.substring(m.indexOf(ValidationProcessor.HIBERNATE_VALIDATION_ERROR_PREFIX)+ValidationProcessor.HIBERNATE_VALIDATION_ERROR_PREFIX.length(), m.length());
      message.append(ivs.getPropertyName()).append("(").append(m).append(")");
    }
   
   
    return new ValidationException(message.toString(), values);
  }
View Full Code Here

    String propName = exception.getPropertyName();
    InvalidValueSerializable iv = new InvalidValueSerializable();
    iv.setMessage(ValidationProcessor.HIBERNATE_VALIDATION_ERROR_PREFIX+exception.getMessage());
    iv.setPropertyName(propName);

    ValidationException ex = new ValidationException(exception.getMessage());
    ex.getInvalidValues().add(iv);
    return ex;
  }
View Full Code Here

  public static ValidationException createUnknownValidationException(
      RuntimeException exception) {
    InvalidValueSerializable iv = new InvalidValueSerializable();
    iv.setPropertyName("UNKNOWN");
    iv.setMessage(exception.getMessage());
    ValidationException ex = new ValidationException();
    ex.getInvalidValues().add(iv);
    return ex;
  }
View Full Code Here

 
  private DefaultValidationProcessor validator = new DefaultValidationProcessor(new TestValidationMessages());
 
  public void testParameterizedCustomMessage() {
   
    ValidationException ex = null;
   
    try {
      ServerValidation.exception("msgKey", "propertyName");
    }catch(ValidationException exc) {
      ex = exc;
    }
   
    assertNotNull("ValidationException must not be null", ex);
   
    InvalidValueSerializable iv = ex.getInvalidValues().get(0);
    assertNotNull("InvalidValueSerializable must not be null", iv);
   
    assertEquals("wrong property name", "propertyName", iv.getPropertyName());
    assertEquals("wrong message", "msgKey", iv.getMessage());
   
   
    try {
      ServerValidation.exception("msgKey", "propertyName", 5, 10, "Alice");
    }catch(ValidationException exc) {
      ex = exc;
    }
   
    assertNotNull("ValidationException must not be null", ex);
   
    iv = ex.getInvalidValues().get(0);
    assertNotNull("InvalidValueSerializable must not be null", iv);
   
    assertEquals("wrong property name", "propertyName", iv.getPropertyName());
    assertEquals("wrong message", "msgKey:5:10:Alice", iv.getMessage());
    System.out.println("key: "+iv.getMessage());
View Full Code Here

   
  }
 
  public void testCustomMessageInvocation() {
   
    ValidationException vEx = null;
    try {
      ServerValidation.exception("someKey", "SomeProperty");
    }catch(ValidationException ex) {
      vEx = ex;
    }
   
    assertNotNull("No exception occured", vEx);
   
//    validator.processServerErrors(vEx);
    validator.localizeMsg(vEx.getInvalidValues().get(0).getMessage());
   
  }
View Full Code Here

public class ValidationSerializationTest extends TestCase {

  public void testSerialization() {
   
    ValidationException ex = null;
    try {
      ServerValidation.exception("someKey", "someProperty", "param1", "param2");
    }catch(ValidationException ex2) {
      ex = ex2;
    }
View Full Code Here

TOP

Related Classes of eu.maydu.gwt.validation.client.ValidationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.