Package org.hibernate.validator

Examples of org.hibernate.validator.ClassValidator


      Component component = name==null ? null : Component.forName(name);
      if (component==null)
      {
         java.util.ResourceBundle bundle = ResourceBundle.instance();
         return bundle==null ?
               new ClassValidator(modelClass) :
               new ClassValidator(modelClass, bundle);
      }
      else
      {
         return component.getValidator();
      }
View Full Code Here


         propertyName = propertyExpression.substring( bracket+1, propertyExpression.length()-2 );
      }
      String modelExpression = propertyExpression.substring(0, dot) + '}';
     
      Object model = context.getApplication().createValueBinding(modelExpression).getValue(context);
      ClassValidator validator = getValidator( model.getClass(), componentName );
      return validator.getPotentialInvalidValues(propertyName, value);
   }
View Full Code Here

   {
      java.util.ResourceBundle bundle = Contexts.isApplicationContextActive() ? //yew, just for testing!
            ResourceBundle.instance() : null;
      Locale locale = bundle==null ?
            new Locale("DUMMY") : bundle.getLocale();
      ClassValidator validator = validators.get(locale);
      if (validator==null)
      {
         validator = bundle==null ?
               new ClassValidator(beanClass) :
               new ClassValidator(beanClass, bundle);
         validators.put(locale, validator);
      }
      return validator;
   }
View Full Code Here

      /**
       * @deprecated use validateValue()
       */
      protected void validate(Class modelClass, String property, Object value)
      {
         ClassValidator validator = Model.forClass(modelClass).getValidator();
         InvalidValue[] ivs = validator.getPotentialInvalidValues(property, value);
         if (ivs.length>0)
         {
            validationFailed = true;
            FacesMessage message = FacesMessages.createFacesMessage( FacesMessage.SEVERITY_WARN, ivs[0].getMessage() );
            FacesContext.getCurrentInstance().addMessage( property, /*TODO*/ message );
View Full Code Here

  @SuppressWarnings("unchecked")
  protected ClassValidator<? extends Object> getValidator(
      FacesContext facesContext, Class<? extends Object> beanClass) {
    // TODO - localization support.
    ValidatorKey key = new ValidatorKey(beanClass, calculateLocale(facesContext));
    ClassValidator result = classValidators.get(key);
    if (null == result) {
      result = createValidator(facesContext, beanClass);
      classValidators.put(key, result);
    }
    return result;
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  protected ClassValidator<? extends Object> createValidator(
      FacesContext facesContext, Class<? extends Object> beanClass) {
    ResourceBundle bundle = createHibernateMessages(facesContext);
    return bundle == null ? new ClassValidator(beanClass)
        : new ClassValidator(beanClass, bundle);
  }
View Full Code Here

        }

        // hibernate would throw an exception on writing,
        // but if we do it manually we can re-wrap hibernate's validation info
        // in a more concise and gwt-friendly way
        ClassValidator validator = new ClassValidator(instance.getClass());
        InvalidValue[] invalidValues = validator.getInvalidValues(instance);

        for (InvalidValue invalidValue : invalidValues)
        {
            validationException.addError(invalidValue.getPropertyName(), invalidValue.getMessage());
        }
View Full Code Here

  @SuppressWarnings("unchecked")
  public static <T>T validate(T o) throws Exception
  {
    ClassValidator<T> v = (ClassValidator<T>)VS.get(o.getClass());
    if (v == null)
      VS.put(o.getClass(), v = new ClassValidator(o.getClass()));
    InvalidValue[] s = v.getInvalidValues(o);
    if (s != null && s.length > 0)
      throw err(new Errs(s));
    return o;
  }
View Full Code Here

TOP

Related Classes of org.hibernate.validator.ClassValidator

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.