Package br.com.caelum.vraptor.validator

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


  public Message i18nConfirmation(String message, Object... parameters) {
    return i18nMessage(message, "confirmation", parameters);
  }

  private I18nMessage i18nMessage(String message, String category, Object... parameters) {
    I18nMessage i18nMessage = new I18nMessage(category, message, parameters);
    i18nMessage.setBundle(bundle);
    return i18nMessage;
  }
View Full Code Here


  /**
   * This method is called when the {@link SizeLimitExceededException} was thrown.
   */
  protected void reportSizeLimitExceeded(final SizeLimitExceededException e, Validator validator) {
    validator.add(new I18nMessage("upload", "file.limit.exceeded", e.getActualSize(), e.getPermittedSize()));
    logger.warn("The file size limit was exceeded. Actual {} permitted {}", e.getActualSize(), e.getPermittedSize());
  }
View Full Code Here

    validator.add(new I18nMessage("upload", "file.limit.exceeded", e.getActualSize(), e.getPermittedSize()));
    logger.warn("The file size limit was exceeded. Actual {} permitted {}", e.getActualSize(), e.getPermittedSize());
  }

  protected void reportFileUploadException(FileUploadException e, Validator validator) {
    validator.add(new I18nMessage("upload", "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

  public Message i18nConfirmation(String message, Object... parameters) {
    return i18nMessage(message, "confirmation", parameters);
  }

  private I18nMessage i18nMessage(String message, String category, Object... parameters) {
    I18nMessage i18nMessage = new I18nMessage(category, message, parameters);
    i18nMessage.setBundle(bundle);
    return i18nMessage;
  }
View Full Code Here

  }

  @Test
  public void shouldSerializeErrorMessages() throws Exception {
    Message normal = new SimpleMessage("category", "The message");
    I18nMessage i18ned = new I18nMessage("category", "message");
    i18ned.setBundle(new SingletonResourceBundle("message", "Something else"));

    XStreamBuilder xstreamBuilder = cleanInstance(new MessageConverter());
    MockSerializationResult result = new MockSerializationResult(null, xstreamBuilder, null, null);
    DefaultStatus status = new DefaultStatus(response, result, config, new JavassistProxifier(), router);
View Full Code Here

  }

  @Test
  public void shouldSerializeErrorMessagesInJSON() throws Exception {
    Message normal = new SimpleMessage("category", "The message");
    I18nMessage i18ned = new I18nMessage("category", "message");
    i18ned.setBundle(new SingletonResourceBundle("message", "Something else"));

    List<JsonSerializer<?>> gsonSerializers = new ArrayList<>();
    List<JsonDeserializer<?>> gsonDeserializers = new ArrayList<>();
    gsonSerializers.add(new MessageGsonConverter());
View Full Code Here

  public List<Message> getErrors() {
    return 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

     * 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
      I18nMessage msg = new I18nMessage("user", "not_logged_user");
      msg.setBundle(bundle);
      result.include("errors", asList(msg));
      result.redirectTo(HomeController.class).login();
      return;
    }
    stack.next();
View Full Code Here

import br.com.caelum.vraptor.validator.I18nMessage;

public class Resources {

  public String getText(String key) {
    I18nMessage message = new I18nMessage("default",key);   
    message.setBundle(new SafeResourceBundle(ResourceBundle.getBundle("messages"), true))
    return message.getMessage();
 
View Full Code Here

  /**
   * This method is called when the {@link SizeLimitExceededException} was thrown.
   */
  protected void reportSizeLimitExceeded(final SizeLimitExceededException e, Validator validator) {
    validator.add(new I18nMessage("upload", "file.limit.exceeded", e.getActualSize(), e.getPermittedSize()));
    logger.warn("The file size limit was exceeded. Actual {} permitted {}", e.getActualSize(), e.getPermittedSize());
  }
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.