Package br.com.caelum.vraptor.util

Examples of br.com.caelum.vraptor.util.FallbackResourceBundle


     */
    public List<Message> getErrors(ResourceBundle bundle) {
      if (isDefaultBundle(this.bundle)) {
        this.bundle = new SafeResourceBundle(bundle);
      } else {
        this.bundle = new FallbackResourceBundle(this.bundle, bundle);
      }
      return getErrors();
    }
View Full Code Here


    public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException {
        Validate validate = method.getMethod().getAnnotation(Validate.class);
        if (validate != null) {
            ResourceBundle validatorBundle = ResourceBundle.getBundle(
                    "org.hibernate.validator.resources.DefaultValidatorMessages", request.getLocale());
            FallbackResourceBundle bundle = new FallbackResourceBundle(localization.getBundle(), validatorBundle);
            String[] names = provider.parameterNamesFor(method.getMethod());
            for (String path : validate.params()) {
                try {
                    Object[] paramValues = parameters.getParameters();
                    Object object = paramFor(names, path, paramValues);
                    BasicValidationErrors newErrors = new BasicValidationErrors();
                    HibernateLogicMethod.validateParam(locator, request, bundle, newErrors, object, path);
                    for (org.vraptor.i18n.ValidationMessage msg : newErrors) {
                        if (msg instanceof FixedMessage) {
                            FixedMessage m = (FixedMessage) msg;
                            String content = bundle.getString(m.getKey());
                            errors.add(new FixedMessage(msg.getPath(), content, msg.getCategory()));
                        } else if (msg instanceof Message) {
                            Message m = (Message) msg;
                            String content = bundle.getString(m.getKey());
                            content = MessageFormat.format(content, new Object[]{m.getParameters()});
                            errors.add(new FixedMessage(msg.getPath(), content, msg.getCategory()));
                        } else {
                            throw new IllegalArgumentException("Unsupported validation message type: " + msg.getClass().getName());
                        }
View Full Code Here

    this.bundle = new Supplier<ResourceBundle>() {
      public ResourceBundle get() {
        if (isDefaultBundle(oldBundle)) {
          return new SafeResourceBundle(bundle.get());
        } else {
          return new FallbackResourceBundle(oldBundle.get(), bundle.get());
        }
      }
    };
    return getErrors();
  }
View Full Code Here

     */
    public List<Message> getErrors(ResourceBundle bundle) {
      if (isDefaultBundle(this.bundle)) {
        this.bundle = new SafeResourceBundle(bundle);
      } else {
        this.bundle = new FallbackResourceBundle(this.bundle, bundle);
      }
      return getErrors();
    }
View Full Code Here

    public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException {
        Validate validate = method.getMethod().getAnnotation(Validate.class);
        if (validate != null) {
            ResourceBundle validatorBundle = ResourceBundle.getBundle(
                    "org.hibernate.validator.resources.DefaultValidatorMessages", request.getLocale());
            FallbackResourceBundle bundle = new FallbackResourceBundle(localization.getBundle(), validatorBundle);
            String[] names = provider.parameterNamesFor(method.getMethod());
            for (String path : validate.params()) {
                try {
                    Object[] paramValues = parameters.getParameters();
                    Object object = paramFor(names, path, paramValues);
                    BasicValidationErrors newErrors = new BasicValidationErrors();
                    HibernateLogicMethod.validateParam(locator, request, bundle, newErrors, object, path);
                    for (org.vraptor.i18n.ValidationMessage msg : newErrors) {
                        if (msg instanceof FixedMessage) {
                            FixedMessage m = (FixedMessage) msg;
                            String content = bundle.getString(m.getKey());
                            errors.add(new FixedMessage(msg.getPath(), content, msg.getCategory()));
                        } else if (msg instanceof Message) {
                            Message m = (Message) msg;
                            String content = bundle.getString(m.getKey());
                            content = MessageFormat.format(content, new Object[]{m.getParameters()});
                            errors.add(new FixedMessage(msg.getPath(), content, msg.getCategory()));
                        } else {
                            throw new IllegalArgumentException("Unsupported validation message type: " + msg.getClass().getName());
                        }
View Full Code Here

      this.bundle = new Supplier<ResourceBundle>() {
      public ResourceBundle get() {
        if (isDefaultBundle(oldBundle)) {
          return new SafeResourceBundle(bundle.get());
        } else {
          return new FallbackResourceBundle(oldBundle.get(), bundle.get());
        }
      }
    };
      return getErrors();
    }
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.util.FallbackResourceBundle

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.