Package br.com.caelum.vraptor.validator

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


  protected 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


    @Put
  public void addToMyList(final User user, final Music music) {
      final User sessionUser = refreshUser();
     
      validator.check(user.getLogin().equals(sessionUser.getLogin()),
              new ValidationMessage("user", "you_cant_add_to_others_list"));

      validator.check(!sessionUser.getMusics().contains(music),
              new ValidationMessage("music", "you_already_have_this_music"));

    validator.onErrorUsePageOf(UsersController.class).home();

    musicDao.add(new MusicOwner(user, music));
View Full Code Here

     * You can use the result even in interceptors, but you can't use Validator.onError* methods because
     * they throw ValidationException.
     */
    if (current == null) {
      // remember added parameters will survive one more request, when there is a redirect
      result.include("errors", asList(new ValidationMessage("user is not logged in", "user")));
      result.redirectTo(HomeController.class).login();
      return;
    }

    stack.next();
View Full Code Here

    final User currentUser = dao.find(login, password);

    // if no user is found, adds an error message to the validator
    // "invalid_login_or_password" is the message key from messages.properties,
    // and that key is used with the fmt taglib in index.jsp, for example: <fmt:message key="error.key">
    validator.check(currentUser != null, new ValidationMessage("login", "invalid_login_or_password"));
   
    // you can use "this" to redirect to another logic from this controller
    validator.onErrorUsePageOf(this).login();

    // the login was valid, add user to session
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

  protected 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

  private boolean isNotEmpty(FileItem item) {
    return item.getName().length() > 0;
  }
 
  private void reportFileUploadException(FileUploadException e) {
    validator.add(new ValidationMessage(e.getMessage(), "file.upload.exception"));
    logger.warn("There was some problem parsing this multipart request, " + "or someone is not sending a RFC1867 compatible multipart request.", e);
  }
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 (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;
      }
    }

    OgnlContext context = createOgnlContextFor(param, bundle);
View Full Code Here

  private void setProperty(OgnlContext context, String key, String[] values, List<Message> errors) {
    try {
      logger.debug("Applying {} with {}",key, values);
      Ognl.setValue(key, context, context.getRoot(), 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

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.