[Open Discussion] Changes to contribute

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[Open Discussion] Changes to contribute


The following forum message was posted by  at http://sourceforge.net/projects/displaytag/forums/forum/249317/topic/4581855:

To fulfill The Artistic License requirements I would like to share changes which
have been made by Sentaca company to displaytag-1.2.

In TableProperties#getInstance() just right before return:

    TableProperties props = (TableProperties) prototypes.get(locale);
    if (props == null) {
      TableProperties lprops = new TableProperties(locale);
      prototypes.put(locale, lprops);
      props = lprops;
     * modified to override messages with messages from spring message source
    if (request != null) {
      WebApplicationContext webApplicationContext =
      MessageSource messageSource;
      if (webApplicationContext.containsBean(BEAN_NAME_MSM_MESSAGESOURCE)) {
        messageSource = (MessageSource)
        // rewrite values for existing keys from spring message source
        Set<Object> keySet = props.properties.keySet();
        for (Object object : keySet) {
          String key = (String) object;
          try {
            String message = messageSource.getMessage(key, null, locale);
            // some properties should not be overriden by keys
            if (!blackList.contains(key) || !key.equals(message)) {
              props.properties.put(key, message);
          } catch (NoSuchMessageException e) {
            log.warn("There is problem with dispaytag property " + key);
      } else {
        log.warn("Bean 'displaytagMessageSource' does not exist");

and we defined blackList as:
   * Hardcoded black list to prevent setting keys as most important
   * configuration properties
  private final static List<String> blackList
= Arrays.asList("factory.requestHelper", "factory.decorator",
      "locale.provider", "locale.resolver", "basic.empty.showtable",
"basic.show.header", "sort.amount",
      "export.amount", "export.decorated", "paging.banner.group_size",
"paging.banner.placement", "css.tr.even",
      "css.tr.odd", "css.th.sorted", "css.th.ascending", "css.th.descending",
"css.table", "css.th.sortable",
      "export.types", "export.csv.class", "export.excel.class", "export.xml.class",
"export.pdf.class", "export.csv",
      "export.csv.label", "export.csv.include_header", "export.csv.filename",
"export.excel", "export.excel.label",
      "export.excel.include_header", "export.excel.filename", "export.xml",
"export.xml.label", "export.xml.filename",
      "export.pdf", "export.pdf.label", "export.pdf.include_header",
"export.pdf.filename", "export.rtf",
      "export.rtf.label", "export.rtf.include_header", "export.rtf.filename");

The changes allow to overwrite displaytag translations and use one provided
by Spring Framework MessageSource. Blacklist has been hardcoded so that messages
from spring will not overwrite important displaytag configuration properties.

Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
displaytag-user mailing list
[hidden email]