Uploaded image for project: 'Tiles'
  1. Tiles
  2. TILES-482

Wildcard configuration doesn't work with cascaded attributes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.3, 2.1.4
    • 2.1.5
    • tiles-core
    • None
    • Windows, WAS 6.1, Struts 2

    • Important

    Description

      I found out that when creating a wildcard configuration with a cascade="true" attribute inside, this attribute doesn't actualy apply to the actual resulting cached configuration.

      Sample configuration xml:

      <definition name="abstract.one" template="/WEB-INF/jsp/one.jsp">
      </definition>
      <definition name="abstract.two" template="/WEB-INF/jsp/two.jsp">
      </definition>
      <definition name="..*" extends="abstract.one">
      <put-attribute name="abstract.one-param1" value="/WEB-INF/jsp/param1.jsp" />
      <put-attribute name="abstract.one-param2" value="abstract.two" />
      <put-attribute name="abstract.two-param1" value="/WEB-INF/jsp/

      {1}

      /

      {2}

      /

      {3}

      .jsp" cascade="true"/>
      </definition>

      Looking at the source code, the problem seems to be in method replaceDefinition of class CachingLocaleUrlDefinitionDAO.java

      If I replace the method to the following, everything is ok:

      protected Definition replaceDefinition(Definition d, String name,
      Map<Integer, String> vars) {
      Definition nudef = new Definition();

      nudef.setExtends(replace(d.getExtends(), vars));
      nudef.setName(name);
      nudef.setPreparer(replace(d.getPreparer(), vars));
      nudef.setTemplateAttribute(replaceVarsInAttribute(d
      .getTemplateAttribute(), vars));

      Set<String> localAttributeNames = d.getLocalAttributeNames();
      if (localAttributeNames != null && !localAttributeNames.isEmpty()) {
      for (String attributeName : localAttributeNames)

      { Attribute attr = d.getLocalAttribute(attributeName); Attribute nuattr = replaceVarsInAttribute(attr, vars); nudef.putAttribute(replace(attributeName, vars), nuattr); }

      }

      /** this is my hack! **/
      Set<String> cascadedAttributeNames = d.getCascadedAttributeNames();
      if (cascadedAttributeNames != null && !cascadedAttributeNames.isEmpty()) {
      for (String attributeName : cascadedAttributeNames)

      { Attribute attr = d.getCascadedAttribute(attributeName); Attribute nuattr = replaceVarsInAttribute(attr, vars); nudef.putAttribute(replace(attributeName, vars), nuattr, true); }

      }

      return nudef;
      }

      Please fix it in next version of Tiles 2.1.x. I don't know if this is working in Tiles 2.2.x, since there is no Struts plugin for Tiles 2.2.x yet.... (who should I blame?)

      Attachments

        1. 482.patch
          1 kB
          Aris Tzoumas

        Issue Links

          Activity

            People

              brenmcguire Antonio Petrelli
              atzoum Aris Tzoumas
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: