Examples of MessageSource


Examples of org.springframework.context.MessageSource

   * @param locale the Locale in which to do the lookup
   * @return the resolved message, or <code>null</code> if not found
   * @see #getParentMessageSource()
   */
  protected String getMessageFromParent(String code, Object[] args, Locale locale) {
    MessageSource parent = getParentMessageSource();
    if (parent != null) {
      if (parent instanceof AbstractMessageSource) {
        // Call internal method to avoid getting the default code back
        // in case of "useCodeAsDefaultMessage" being activated.
        return ((AbstractMessageSource) parent).getMessageInternal(code, args, locale);
      }
      else {
        // Check parent MessageSource, returning null if not found there.
        return parent.getMessage(code, args, null, locale);
      }
    }
    // Not found in parent either.
    return null;
  }
View Full Code Here

Examples of org.springframework.context.MessageSource

  /**
   * Resolve the specified message into a concrete message String.
   * The returned message String should be unescaped.
   */
  protected String resolveMessage() throws JspException, NoSuchMessageException {
    MessageSource messageSource = getMessageSource();
    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();
      resolvedMessage = (MessageSourceResolvable)
          ExpressionEvaluationUtils.evaluate("message", expr, MessageSourceResolvable.class, pageContext);
    }

    if (resolvedMessage != null) {
      // We have a given MessageSourceResolvable.
      return messageSource.getMessage(resolvedMessage, getRequestContext().getLocale());
    }

    String resolvedCode = ExpressionEvaluationUtils.evaluateString("code", this.code, pageContext);
    String resolvedText = ExpressionEvaluationUtils.evaluateString("text", this.text, pageContext);

    if (resolvedCode != null || resolvedText != null) {
      // We have a code or default text that we need to resolve.
      Object[] argumentsArray = resolveArguments(this.arguments);
      if (resolvedText != null) {
        // We have a fallback text to consider.
        return messageSource.getMessage(
            resolvedCode, argumentsArray, resolvedText, getRequestContext().getLocale());
      }
      else {
        // We have no fallback text to consider.
        return messageSource.getMessage(
            resolvedCode, argumentsArray, getRequestContext().getLocale());
      }
    }

    // All we have is a specified literal text.
View Full Code Here

Examples of org.springframework.context.MessageSource

   * @param locale the Locale in which to do the lookup
   * @return the resolved message, or <code>null</code> if not found
   * @see #getParentMessageSource()
   */
  protected String getMessageFromParent(String code, Object[] args, Locale locale) {
    MessageSource parent = getParentMessageSource();
    if (parent != null) {
      if (parent instanceof AbstractMessageSource) {
        // Call internal method to avoid getting the default code back
        // in case of "useCodeAsDefaultMessage" being activated.
        return ((AbstractMessageSource) parent).getMessageInternal(code, args, locale);
      }
      else {
        // Check parent MessageSource, returning null if not found there.
        return parent.getMessage(code, args, null, locale);
      }
    }
    // Not found in parent either.
    return null;
  }
View Full Code Here

Examples of org.springframework.context.MessageSource

      // manually set the size, otherwise sometimes the overlay is not
      // shown (it has size 0,0)
      getControl().setSize(getControl().getPreferredSize());

      if (visible) {
        MessageSource messageSource = (MessageSource) ApplicationServicesLocator.services().getService(
            MessageSource.class);
        String dirtyTooltip = messageSource.getMessage(DIRTY_MESSAGE_KEY, new Object[] {
            formModel.getFieldFace(propertyName).getDisplayName(), originalValueHolder.getValue() }, Locale
            .getDefault());
        dirtyLabel.setToolTipText(dirtyTooltip);

        String revertTooltip = messageSource.getMessage(REVERT_MESSAGE_KEY, new Object[] { formModel
            .getFieldFace(propertyName).getDisplayName() }, Locale.getDefault());
        revertButton.setToolTipText(revertTooltip);
      }
    }
View Full Code Here

Examples of org.springframework.context.MessageSource

      GoogleSearch googleSearch = new GoogleSearch();
      googleSearch.setKey(getGoogleKey());
      googleSearch.setQueryString(query);
      googleSearch.setStartResult(startResult);
      try{
        MessageSource messageSource = (MessageSource)ApplicationServicesLocator.services().getService(MessageSource.class);
        String title = messageSource.getMessage(PROGESS_MESSAGE, new Object[]{}, Locale.getDefault());
        getStatusBar().getProgressMonitor().taskStarted(title, StatusBarProgressMonitor.UNKNOWN);
        return googleSearch.doSearch();
      }
      finally{
        getStatusBar().getProgressMonitor().done();
View Full Code Here

Examples of org.springframework.context.MessageSource

   * Confirms that a {@link TitleConfigurable} object will have its title set
   * correctly, as retrieved from a MessageSource using the key
   * 'beanName.title'.
   */
  public void testConfigureTitleConfigurable() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusTitleable";
    String messageCode = objectName + ".title";
    String message = "bogusTitle";

    EasyMock.expect(messageSource.getMessage(messageCode, null, Locale.getDefault())).andReturn(message);

    TitleConfigurable configurable = (TitleConfigurable) EasyMock.createMock(TitleConfigurable.class);
    configurable.setTitle(message);

    EasyMock.replay(messageSource);
View Full Code Here

Examples of org.springframework.context.MessageSource

    EasyMock.verify(messageSource);
    EasyMock.verify(configurable);
  }

  public void testConfigureTitleConfigurableWithNoTitleFound() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusTitleable";
    String messageCode = objectName + ".title";

    EasyMock.expect(messageSource.getMessage(messageCode, null, Locale.getDefault())).andReturn(null);

    TitleConfigurable configurable = (TitleConfigurable) EasyMock.createMock(TitleConfigurable.class);

    EasyMock.replay(messageSource);
    EasyMock.replay(configurable);
View Full Code Here

Examples of org.springframework.context.MessageSource

   * Confirms that a {@link DescriptionConfigurable} object will have its
   * description and caption set correctly, as retrieved from a MessageSource
   * using the key 'beanName.description' and 'beanName.caption' respectively.
   */
  public void testDescriptionConfigurable() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusDescriptionConfigurable";
    String descriptionCode = objectName + ".description";
    String captionCode = objectName + ".caption";
    String description = "bogusDescription";
    String caption = "bogusCaption";

    EasyMock.expect(messageSource.getMessage(descriptionCode, null, Locale.getDefault())).andReturn(description);
    EasyMock.expect(messageSource.getMessage(captionCode, null, Locale.getDefault())).andReturn(caption);

    DescriptionConfigurable configurable = (DescriptionConfigurable) EasyMock
        .createMock(DescriptionConfigurable.class);
    configurable.setDescription(description);
    configurable.setCaption(caption);
View Full Code Here

Examples of org.springframework.context.MessageSource

    EasyMock.verify(messageSource);
    EasyMock.verify(configurable);
  }

  public void testDescriptionConfigurableWithNoDescriptionFound() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusDescriptionConfigurable";
    String descriptionCode = objectName + ".description";
    String captionCode = objectName + ".caption";

    EasyMock.expect(messageSource.getMessage(descriptionCode, null, Locale.getDefault())).andReturn(null);
    EasyMock.expect(messageSource.getMessage(captionCode, null, Locale.getDefault())).andReturn(null);

    DescriptionConfigurable configurable = (DescriptionConfigurable) EasyMock
        .createMock(DescriptionConfigurable.class);

    EasyMock.replay(messageSource);
View Full Code Here

Examples of org.springframework.context.MessageSource

   * Confirms that a {@link LabelConfigurable} object will have its label set
   * correctly, as retrieved from a MessageSource using the key
   * 'beanName.label'.
   */
  public void testLabelConfigurable() {
    MessageSource messageSource = (MessageSource) EasyMock.createMock(MessageSource.class);

    DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(messageSource);

    String objectName = "bogusLabelable";
    String messageCode = objectName + ".label";
    String message = "bogusLabelInfo";
    LabelInfo expectedLabelInfo = LabelInfo.valueOf(message);

    EasyMock.expect(messageSource.getMessage(messageCode, null, Locale.getDefault())).andReturn(message);

    LabelConfigurable configurable = (LabelConfigurable) EasyMock.createMock(LabelConfigurable.class);
    configurable.setLabelInfo(expectedLabelInfo);

    EasyMock.replay(messageSource);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.