Package br.com.caelum.vraptor.validator

Examples of br.com.caelum.vraptor.validator.ValidationMessage


      /**
       * You can use the result even in interceptors.
       */
      if (info.getUser() == null) {
        // remember added parameters will survive one more request, when there is a redirect
        result.include("errors", Arrays.asList(new ValidationMessage("user is not logged in", "user")));
        result.redirectTo(HomeController.class).login();
      } else {
        dao.refresh(info.getUser());
        // continues execution
        stack.next(method, resourceInstance);
View Full Code Here


    if (requestNames.containsKey(param.name)) {
      String[] values = requestNames.get(param.name);
      try {
        return createSimpleParameter(param, values, bundle);
      } catch(ConversionError ex) {
        errors.add(new ValidationMessage(ex.getMessage(), param.name));
        return null;
      }
    }

    try {
View Full Code Here

  private void setProperty(String name, String key, String[] values, List<Message> errors) {
    try {
      logger.debug("Applying {} with {}",key, values);
      ognl.setValue(name, key, values);
    } catch (ConversionError ex) {
      errors.add(new ValidationMessage(ex.getMessage(), key));
    }
  }
View Full Code Here

      try {
        Parameter parameter = parameters.namedAfter(target);
        return converterForTarget(target).convert(parameter.getValue(), target.getClassType(), localization.getBundle());
      }
      catch (ConversionError ex) {
        validator.add(new ValidationMessage(ex.getMessage(), target.getName()));
      }
      catch (Exception e) {
        if (e.getClass().isAnnotationPresent(ValidationException.class)) {
          validator.add(new ValidationMessage(e.getLocalizedMessage(), target.getName()));
        } else {
          throw new InvalidParameterException("Exception when trying to instantiate " + target, e);
        }
      }
      return null;
View Full Code Here

      try {
        Parameter parameter = parameters.namedAfter(target);
        return converterForTarget(target).convert(parameter.getValue(), target.getClassType(), localization.getBundle());
      }
      catch (ConversionError ex) {
        validator.add(new ValidationMessage(ex.getMessage(), target.getName()));
      }
      catch (Exception e) {
        if (e.getClass().isAnnotationPresent(ValidationException.class)) {
          validator.add(new ValidationMessage(e.getLocalizedMessage(), target.getName()));
        } else {
          throw new InvalidParameterException("Exception when trying to instantiate " + target, e);
        }
      }
      return null;
View Full Code Here

        if (logger.isDebugEnabled()) {
          logger.debug("Applying " + key + " with " + Arrays.toString(values));
        }
        Ognl.setValue(key, context, root, values.length == 1 ? values[0] : values);
      } catch (ConversionError ex) {
        errors.add(new ValidationMessage(ex.getMessage(), key));
      } catch (MethodFailedException e) { // setter threw an exception

        Throwable cause = e.getCause();
        if (cause.getClass().isAnnotationPresent(ValidationException.class)) {
          errors.add(new ValidationMessage(cause.getLocalizedMessage(), key));
        } else {
          throw new InvalidParameterException("unable to parse expression '" + key + "'", e);
        }

      } catch (NoSuchPropertyException ex) {
View Full Code Here

            checkMaxSize();
            return request.getParts();

        } catch (IllegalStateException e) {
            logger.warn("The file size limit was exceeded.", e);
            validator.add(new ValidationMessage("upload", "file.limit.exceeded"));

            return Collections.emptyList();

        } catch (Exception e) {
            throw new InterceptionException(e);
View Full Code Here

      return null;
    }
  }
  private void handleException(Target<?> target, Throwable e) {
    if (e.getClass().isAnnotationPresent(ValidationException.class)) {
      errors.add(new ValidationMessage(e.getLocalizedMessage(), target.getName()));
    } else if (e.getCause() == null) {
      throw new InvalidParameterException("Exception when trying to instantiate " + target, e);
    } else {
      handleException(target, e.getCause());
    }
View Full Code Here

    public Object instantiate(Target<?> target, Parameters parameters) {
      try {
        Parameter parameter = parameters.namedAfter(target);
        return converterForTarget(target).convert(parameter.getValue(), target.getClassType(), localization.getBundle());
      } catch (ConversionError ex) {
        errors.add(new ValidationMessage(ex.getMessage(), target.getName()));
      } catch (IllegalStateException e) {
        return setPropertiesAfterConversions(target, parameters);
      }
      return null;
    }
View Full Code Here

    if (requestNames.containsKey(param.name)) {
      String[] values = requestNames.get(param.name);
      try {
        return createSimpleParameter(param, values, bundle);
      } catch(ConversionError ex) {
        errors.add(new ValidationMessage(ex.getMessage(), param.name));
        return null;
      }
    }

    try {
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.validator.ValidationMessage

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.