Examples of MessageSource


Examples of org.springframework.context.MessageSource

  }

  public void testMessageSourceAware() {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
        "/org/springframework/context/support/test/context*.xml");
    MessageSource messageSource = (MessageSource) ctx.getBean("messageSource");
    Service service1 = (Service) ctx.getBean("service");
    assertEquals(ctx, service1.getMessageSource());
    Service service2 = (Service) ctx.getBean("service2");
    assertEquals(ctx, service2.getMessageSource());
    AutowiredService autowiredService1 = (AutowiredService) ctx.getBean("autowiredService");
View Full Code Here

Examples of org.springframework.context.MessageSource

    assertEquals(13, beanCount);
    context.refresh();

    FooServiceImpl fooService = (FooServiceImpl) context.getBean("fooService");
    StaticListableBeanFactory myBf = (StaticListableBeanFactory) context.getBean("myBf");
    MessageSource ms = (MessageSource) context.getBean("messageSource");
    assertTrue(fooService.isInitCalled());
    assertEquals("bar", fooService.foo(123));
    assertSame(context.getDefaultListableBeanFactory(), fooService.beanFactory);
    assertEquals(2, fooService.listableBeanFactory.size());
    assertSame(context.getDefaultListableBeanFactory(), fooService.listableBeanFactory.get(0));
View Full Code Here

Examples of org.springframework.context.MessageSource

    sac.registerSingleton("singletonFactoryToBeProxied", DummyFactory.class);
    sac.registerSingleton("autowiredIndexedTestBean", IndexedTestBean.class);

    sac.refresh();

    MessageSource messageSource = (MessageSource) sac.getBean("messageSource");
    ITestBean singletonToBeProxied = (ITestBean) sac.getBean("singletonToBeProxied");
    assertFalse(Proxy.isProxyClass(messageSource.getClass()));
    assertTrue(Proxy.isProxyClass(singletonToBeProxied.getClass()));
    assertTrue(Proxy.isProxyClass(singletonToBeProxied.getSpouse().getClass()));

    // test whether autowiring succeeded with auto proxy creation
    assertEquals(sac.getBean("autowiredIndexedTestBean"), singletonToBeProxied.getNestedIndexedBean());
View Full Code Here

Examples of org.springframework.context.MessageSource

    sac.registerSingleton("singletonNoInterceptor", TestBean.class);
    sac.registerSingleton("singletonToBeProxied", TestBean.class);
    sac.registerPrototype("prototypeToBeProxied", TestBean.class);
    sac.refresh();

    MessageSource messageSource = (MessageSource) sac.getBean("messageSource");
    ITestBean singletonNoInterceptor = (ITestBean) sac.getBean("singletonNoInterceptor");
    ITestBean singletonToBeProxied = (ITestBean) sac.getBean("singletonToBeProxied");
    ITestBean prototypeToBeProxied = (ITestBean) sac.getBean("prototypeToBeProxied");
    assertFalse(AopUtils.isCglibProxy(messageSource));
    assertTrue(AopUtils.isCglibProxy(singletonNoInterceptor));
View Full Code Here

Examples of org.springframework.context.MessageSource

  /**
   * Resolves messages.
   */
  private static class MessageSourcePropertyAccessor implements PropertyAccessor {
    public Object getProperty(Map context, Object target, Object name) throws OgnlException {
      MessageSource messageSource = (MessageSource) target;
      ExternalContext externalContext;
      Object root = Ognl.getRoot(context);
      if (root instanceof RequestContext) {
        externalContext = ((RequestContext) root).getExternalContext();
      } else {
        externalContext = ExternalContextHolder.getExternalContext();
      }
      if (externalContext != null) {
        return messageSource.getMessage(name.toString(), null, null, externalContext.getLocale());
      } else {
        return messageSource.getMessage(name.toString(), null, null, null);
      }
    }
View Full Code Here

Examples of org.springframework.context.MessageSource

        ValidatorResources resources = getValidatorResources();

        Form form = resources.getForm(locale, formName);
        if (form != null) {
            if ("true".equalsIgnoreCase(dynamicJavascript)) {
                MessageSource messages = getMessageSource();

                List lActions = new ArrayList();
                List lActionMethods = new ArrayList();

                // Get List of actions for this Form
View Full Code Here

Examples of org.springframework.context.MessageSource

        _parent = (ValueListSpaceTag) JspUtils.getParent(this,
                ValueListSpaceTag.class);

        Locale local = _parent.getConfig().getLocaleResolver().resolveLocale(
                (HttpServletRequest) pageContext.getRequest());
        MessageSource message = _parent.getConfig().getMessageSource();
      ValueListInfo valueListInfo = getValueListInfo();

        // Create a map of parameters that are used to generate the links.
        parameters = new HashMap(_parent.getTableInfo().getParameters());
        // todo: set these correctly
      parameters.put(ParameterNames.sortColumn, valueListInfo.getSortingColumn());
      parameters.put(ParameterNames.sortDirection, valueListInfo.getSortingDirection());

        StringBuffer sb = new StringBuffer();

        page = _parent.getValueList().getValueListInfo().getPagingPage();
        total = _parent.getValueList().getValueListInfo()
                .getTotalNumberOfEntries();
        qtyOnPage = _parent.getValueList().getValueListInfo()
                .getPagingNumberPer();
        numberOfPages = _parent.getValueList().getValueListInfo()
                .getTotalNumberOfPages();

        currentPage = (int) (page - (pages / 2));
        if (currentPage < 1)
        {
            currentPage = 1;
        }

        maxPage = (currentPage - 1) + pages;
        if (maxPage > numberOfPages)
        {
            currentPage -= (maxPage - numberOfPages);
            maxPage = numberOfPages;
        }
        if (maxPage < 2)
        {
            maxPage = 0;
        }
        if (currentPage < 1)
        {
            currentPage = 1;
        }

        sb.append("\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\""
                + (getAttributes()==null ? "":(" "+getAttributes()))
                + ">\n");
        sb.append("  <tr>\n");

        if (showSummary == true)
        {
            sb.append(generateSumary(message, local));
            sb.append("     <td align=\"right\">\n");
            sb
                    .append("\n      <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" >\n");
            sb.append("          <tr>\n");

        }

        String value = null;

        String delim = _parent.getConfig().getDisplayHelper().help(pageContext,
                message.getMessage("paging.delim", null, "", local));

        sb
                .append(generateFocusControl(_parent.getValueList()
                        .getValueListInfo(), delim, message, local));
View Full Code Here

Examples of org.springframework.context.MessageSource

     */
    public int doEndTag() throws JspException
    {
        Locale local = _parent.getConfig().getLocaleResolver().resolveLocale(
                (HttpServletRequest) pageContext.getRequest());
        MessageSource message = _parent.getConfig().getMessageSource();

        StringBuffer sb = new StringBuffer();

        String value = null;
        String delim = _parent.getConfig().getDisplayHelper().help(pageContext,
                message.getMessage("paging.delim", null, local));

        if (!(getBodyContent() != null && getBodyContent().getString() != null && getBodyContent()
                .getString().trim().length() > 0))
        {
            while(currentPage <= maxPage)
View Full Code Here

Examples of org.springframework.context.MessageSource

    /**
     * @see I18nResourceProvider#getResource(String, String, Tag, PageContext)
     */
    public String getResource(String resourceKey, String defaultValue, Tag tag, PageContext pageContext)
    {
        MessageSource messageSource = RequestContextUtils.getWebApplicationContext(pageContext.getRequest());
        if (messageSource == null)
        {
            log.warn("messageSource not found");
            return null;
        }

        // if resourceKey isn't defined either, use defaultValue
        String key = (resourceKey != null) ? resourceKey : defaultValue;

        String message = null;

        message = messageSource.getMessage(key, null, null, RequestContextUtils
            .getLocale((HttpServletRequest) pageContext.getRequest()));

        // if user explicitely added a titleKey we guess this is an error
        if (message == null && resourceKey != null)
        {
View Full Code Here

Examples of org.springframework.context.MessageSource

        return getAsHtml(item, null, null, messageSource, locale);
    }
   
    public static String getAsHtml(Item item, HttpServletRequest request, HttpServletResponse response) {
        Locale locale = RequestContextUtils.getLocale(request);
        MessageSource messageSource = RequestContextUtils.getWebApplicationContext(request);       
        return getAsHtml(item, request, response, messageSource, locale);
    }   
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.