Package eu.maydu.gwt.validation.client

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


    return this;
  }
 
   
  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 {
View Full Code Here


   * @param msgKey The key for the custom message
   * @param propertyName The property name of the field the validation error belongs to
   * @throws ValidationException The exception is always thrown by this method (thats its use ;>)
   */
  public static void exception(String msgKey, String propertyName, Object... params) throws ValidationException {
    InvalidValueSerializable iv = new InvalidValueSerializable();
   
    if(params != null && params.length > 0) {
     
      //merge parameters into message key
      for(Object o: params) {
        if(o != null)
          msgKey += ":"+o.toString();
        else msgKey += ":";
      }
    }
   
    iv.setMessage(msgKey);
    iv.setPropertyName(propertyName);
    ValidationException ex = new ValidationException();
    ex.getInvalidValues().add(iv);
    throw ex;
  }
View Full Code Here

   
    if(throwOnFirstError)
      exception(msgKey, propertyName, params);
    else {
      msgKey = addParamsToMessageKey(msgKey, params);
      InvalidValueSerializable iv = new InvalidValueSerializable();
      iv.setMessage(msgKey);
      iv.setPropertyName(propertyName);
      invalidPool.add(iv);
    }
    return this;
     
  }
View Full Code Here

   
    return new ValidationException(message.toString(), values);
  }
 
  private static InvalidValueSerializable getInvalidValueSerializable(InvalidValue iv) {
    InvalidValueSerializable value =
      new InvalidValueSerializable(ValidationProcessor.HIBERNATE_VALIDATION_ERROR_PREFIX+iv.getMessage(), iv.getPropertyName()/*, iv.getValue(), iv.getBean()*/);
    return value;
  }
View Full Code Here

  }
 
 
  public static ValidationException createValidationException(PropertyValueException exception) {
    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

    return ex;
  }

  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

      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

   
    ex = ValidationProcessorUtils.deserializeValidationException(serialized);
   
    assertNotNull("Exception must not be null", ex);
    assertEquals("exactly one iv object expected", 1, ex.getInvalidValues().size());
    InvalidValueSerializable iv = ex.getInvalidValues().get(0);
    assertEquals("property error", "someProperty", iv.getPropertyName());
    assertEquals("message error", "someKey:param1:param2", iv.getMessage());
   
  }
View Full Code Here

   
    ex = ValidationProcessorUtils.deserializeValidationException(serialized);
   
    assertNotNull("Exception must not be null", ex);
    assertEquals("exactly two iv object expected", 2, ex.getInvalidValues().size());
    InvalidValueSerializable iv = ex.getInvalidValues().get(0);
    assertEquals("property error", "someProperty", iv.getPropertyName());
    assertEquals("message error", "someKey:param1:param2", iv.getMessage());
   
    iv = ex.getInvalidValues().get(1);
    assertEquals("property error", "someProperty2", iv.getPropertyName());
    assertEquals("message error", "someKey2:param1:param2:param3", iv.getMessage());
   
  }
View Full Code Here

    return this;
  }
 
   
  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 {
View Full Code Here

TOP

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

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.