Package br.com.caelum.vraptor.validator

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


    this.container = container;
    this.localization = localization;
    }

  public I18nMessageSerialization from(String category, String key, Object...params) {
    I18nMessage i18nMessage = new I18nMessage(category, key, params);
    i18nMessage.setBundle(localization.getBundle());
    this.i18nMessage = i18nMessage;
    return this;
  }
View Full Code Here


  private void validateStatement(Statement statement, List<String> parameters) {
    try {
      statement.validate(statements,parameters);
    } catch (IllegalArgumentException e) {
      validator.add(new I18nMessage("hql", "invalid_hql", e.getCause().getMessage()));
      validator.onErrorRedirectTo(this).index(null);
    }
  }
View Full Code Here

  public List<Message> getErrors() {
    return Collections.unmodifiableList(errors);
  }
 
  public boolean containsMessage(String messageKey, Object... messageParameters) {
    I18nMessage expectedMessage = new I18nMessage("validation", messageKey, messageParameters);
    expectedMessage.setBundle(ResourceBundle.getBundle("messages"));
    for(Message error : this.getErrors()) {
      if(expectedMessage.getMessage().equals(error.getMessage())) {
        return true;
      }
    }
   
    return false;
View Full Code Here

  public List<Message> getErrors() {
    return Collections.unmodifiableList(errors);
  }
 
  public boolean containsMessage(String messageKey, Object... messageParameters) {
    I18nMessage expectedMessage = new I18nMessage("validation", messageKey, messageParameters);
    expectedMessage.setBundle(ResourceBundle.getBundle("messages"));
    for(Message error : this.getErrors()) {
      if(expectedMessage.getMessage().equals(error.getMessage())) {
        return true;
      }
    }
   
    return false;
View Full Code Here

     * file.limit.exceeded using {@link Validations}.
     *
     * @param e
     */
    protected void reportSizeLimitExceeded(final SizeLimitExceededException e) {
        validator.add(new I18nMessage("upload", "file.limit.exceeded", e.getActualSize(), e.getPermittedSize()));
        logger.warn("The file size limit was exceeded.", e);
    }
View Full Code Here

     * maxRequestSize() attributes in a Filter.
     *
     * @param e
     */
    protected void reportSizeLimitExceeded(final IllegalStateException e) {
        validator.add(new I18nMessage("upload", "servlet3.upload.filesize.exceeded"));
        logger.warn("The file size limit was exceeded.", e);
    }
View Full Code Here

  @Post("/signin")
  public void signin(String email, String password, String urlAfterLogin) {
    boolean isAuthenticated = authenticator.authenticate(email, password);
    if (!isAuthenticated) {
      validator.add(new I18nMessage("vraptor.mauth.signin.fail",
          "vraptor.mauth.signin.fail"));
      result.include("email", email);
      validator.onErrorUse(page()).redirectTo("/");
    }
View Full Code Here

   * file.limit.exceeded using {@link Validations}.
   *
   * @param e
   */
  protected void reportSizeLimitExceeded(final SizeLimitExceededException e) {
    validator.add(new I18nMessage("upload", "file.limit.exceeded", e.getActualSize(), e.getPermittedSize()));
    logger.warn("The file size limit was exceeded.", e);
  }
View Full Code Here

    this.container = container;
    this.localization = localization;
  }

  public I18nMessageSerialization from(String category, String key, Object...params) {
    I18nMessage i18nMessage = new I18nMessage(category, key, params);
    i18nMessage.setBundle(localization.getBundle());
    this.i18nMessage = i18nMessage;
    return this;
  }
View Full Code Here

  @Test
  public void shouldSerializeI18nMessage() {
    String expectedResult = "{\"category\":\"validation\",\"message\":\"you are underage\"}";
   
    I18nMessage message = new I18nMessage("validation", "underage");
    message.setBundle(ResourceBundle.getBundle("messages"));
    JsonElement jsonElement = new MessageSerializer().serialize(message, mock(Type.class), mock(JsonSerializationContext.class));
   
    assertEquals(expectedResult, jsonElement.getAsJsonObject().toString());
  }
View Full Code Here

TOP

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

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.