Tiles
  1. Tiles
  2. TILES-482

Wildcard configuration doesn't work with cascaded attributes

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.3, 2.1.4
    • Fix Version/s: 2.1.5
    • Component/s: tiles-core
    • Labels:
      None
    • Environment:

      Windows, WAS 6.1, Struts 2

    • Flags:
      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?)

      1. 482.patch
        1 kB
        Aris Tzoumas

        Issue Links

          Activity

          Hide
          Antonio Petrelli added a comment -

          This bug is related to TILES-454, however the solution is different due to refactoring in Tiles 2.2.x.
          Aris, please attach a patch using "svn diff" if you want it to be applied.

          Show
          Antonio Petrelli added a comment - This bug is related to TILES-454 , however the solution is different due to refactoring in Tiles 2.2.x. Aris, please attach a patch using "svn diff" if you want it to be applied.
          Hide
          Aris Tzoumas added a comment -

          patch for tiles v 2.1.4

          Show
          Aris Tzoumas added a comment - patch for tiles v 2.1.4
          Hide
          Antonio Petrelli added a comment -

          Applied patch by Aris Tzoumas.
          Thank Aris!

          Show
          Antonio Petrelli added a comment - Applied patch by Aris Tzoumas. Thank Aris!

            People

            • Assignee:
              Antonio Petrelli
              Reporter:
              Aris Tzoumas
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development