Package org.springframework.context

Examples of org.springframework.context.MessageSourceResolvable


   *
   * @param messageKeys The keys to use when looking for the message.
   * @return the message found in the resources or a default message.
   */
  protected String getRequiredMessage(final String[] messageKeys) {
    MessageSourceResolvable resolvable = new MessageSourceResolvable() {

      public String[] getCodes() {
        return messageKeys;
      }

View Full Code Here


    protected String getMessage(String messageCode) {
        return getApplicationContext().getMessage(messageCode, null, messageCode, Locale.getDefault());
    }

    protected String getMessage(final String[] messageCodes) {
        MessageSourceResolvable resolvable = new MessageSourceResolvable() {
            public String[] getCodes() {
                return messageCodes;
            }

            public Object[] getArguments() {
View Full Code Here

    protected String getMessage(String messageCode, Object[] args) {
        return getApplicationContext().getMessage(messageCode, args, messageCode, Locale.getDefault());
    }

    protected String getMessage(final String[] messageCodes, final Object[] args) {
        MessageSourceResolvable resolvable = new MessageSourceResolvable() {
            public String[] getCodes() {
                return messageCodes;
            }

            public Object[] getArguments() {
View Full Code Here

    if (messageSource == null) {
      throw new JspTagException("No corresponding MessageSource found");
    }

    // Evaluate the specified MessageSourceResolvable, if any.
    MessageSourceResolvable resolvedMessage = null;
    if (this.message instanceof MessageSourceResolvable) {
      resolvedMessage = (MessageSourceResolvable) this.message;
    }
    else if (this.message != null) {
      String expr = this.message.toString();
View Full Code Here

      return arguments;
    }
    for (int i = 0; i < arguments.length; i++) {
      Object arg = arguments[i];
      if (arg instanceof MessageSourceResolvable) {
        MessageSourceResolvable resolvable = (MessageSourceResolvable)arg;
        String[] codes = resolvable.getCodes();
        boolean resolved = false;
        if (this.messageResources != null) {
          for (int j = 0; j < codes.length; j++) {
            String code = codes[j];
            if (this.messageResources.isPresent(this.locale, code)) {
              arguments[i] = this.messageResources.getMessage(
                  this.locale, code, resolveArguments(resolvable.getArguments()));
              resolved = true;
              break;
            }
          }
        }
        if (!resolved) {
          arguments[i] = resolvable.getDefaultMessage();
        }
      }
    }
    return arguments;
  }
View Full Code Here

      return true;
    }
    if (!(other instanceof MessageSourceResolvable)) {
      return false;
    }
    MessageSourceResolvable otherResolvable = (MessageSourceResolvable) other;
    return ObjectUtils.nullSafeEquals(getCodes(), otherResolvable.getCodes()) &&
        ObjectUtils.nullSafeEquals(getArguments(), otherResolvable.getArguments()) &&
        ObjectUtils.nullSafeEquals(getDefaultMessage(), otherResolvable.getDefaultMessage());
  }
View Full Code Here

    if (messageSource == null) {
      throw new JspTagException("No corresponding MessageSource found");
    }

    // Evaluate the specified MessageSourceResolvable, if any.
    MessageSourceResolvable resolvedMessage = null;
    if (this.message instanceof MessageSourceResolvable) {
      resolvedMessage = (MessageSourceResolvable) this.message;
    }
    else if (this.message != null) {
      String expr = this.message.toString();
View Full Code Here

      return true;
    }
    if (!(other instanceof MessageSourceResolvable)) {
      return false;
    }
    MessageSourceResolvable otherResolvable = (MessageSourceResolvable) other;
    return ObjectUtils.nullSafeEquals(getCodes(), otherResolvable.getCodes());
  }
View Full Code Here

      return arguments;
    }
    for (int i = 0; i < arguments.length; i++) {
      Object arg = arguments[i];
      if (arg instanceof MessageSourceResolvable) {
        MessageSourceResolvable resolvable = (MessageSourceResolvable)arg;
        String[] codes = resolvable.getCodes();
        boolean resolved = false;
        if (this.messageResources != null) {
          for (int j = 0; j < codes.length; j++) {
            String code = codes[j];
            if (this.messageResources.isPresent(this.locale, code)) {
              arguments[i] = this.messageResources.getMessage(
                  this.locale, code, resolveArguments(resolvable.getArguments()));
              resolved = true;
              break;
            }
          }
        }
        if (!resolved) {
          arguments[i] = resolvable.getDefaultMessage();
        }
      }
    }
    return arguments;
  }
View Full Code Here

    if (objectName != null) {
      buf.append(resolveObjectName(objectName));
      buf.append(' ');
    }
    for (int i = 0; i < args.length - 1; i++) {
      MessageSourceResolvable arg = args[i];
      buf.append(messages.getMessage(arg, locale));
      buf.append(' ');
    }
    buf.append(messages.getMessage(args[args.length - 1], locale));
    buf.append(".");
View Full Code Here

TOP

Related Classes of org.springframework.context.MessageSourceResolvable

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.