Package org.springframework.context

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


        _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

     */
    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

    /**
     * @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

        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

  /**
   * 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

    }
    if (base == null && RESOURCE_BUNDLE_KEY.equals(property)) {
      context.setPropertyResolved(true);
      return MessageSource.class;
    } else if (base instanceof MessageSource) {
      MessageSource messageSource = (MessageSource) base;
      String message = messageSource.getMessage(property.toString(), null, null, getLocale());
      if (message != null) {
        context.setPropertyResolved(true);
        return String.class;
      }
    }
View Full Code Here

    }
    if (base == null && RESOURCE_BUNDLE_KEY.equals(property)) {
      context.setPropertyResolved(true);
      return getMessageSource();
    } else if (base instanceof MessageSource) {
      MessageSource messageSource = (MessageSource) base;
      String message = messageSource.getMessage(property.toString(), null, null, getLocale());
      if (message != null) {
        context.setPropertyResolved(true);
        return message;
      }
    }
View Full Code Here

    private String lookupFormat(String name) {
        String format = CACHED_DATE_FORMATS.get(name);
        if (format == null) {
            GrailsWebRequest webRequest = GrailsWebRequest.lookup(request);
            if (webRequest != null) {
                MessageSource messageSource = webRequest.getApplicationContext();
                if (messageSource != null) {
                    format = messageSource.getMessage("date." + name + ".format", EMPTY_ARGS, webRequest.getLocale());
                    if (format != null) {
                        CACHED_DATE_FORMATS.put(name, format);
                    }
                }
            }
View Full Code Here

        // test multipart support
        assertTrue(ctx.getBean(GrailsApplication.MULTIPART_RESOLVER_BEAN) instanceof StandardServletMultipartResolver);

        // test message source
        MessageSource ms = getBean(ctx, GrailsApplication.MESSAGE_SOURCE_BEAN);
        assertNotNull(ms);

        // test domain class setup correctly in the ctx
        GrailsDomainClass domainClass = getBean(ctx, "TestDomainClass");
View Full Code Here

TOP

Related Classes of org.springframework.context.MessageSource

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.