Tiles
  1. Tiles
  2. TILES-220

[tiles] use of wildcard in tiles-defs.xml as for wildcard mappings

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.4
    • Fix Version/s: 2.1.0
    • Component/s: tiles-core
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      Description

      Wildcard mappings is a interesting new feature in struts 1.2.x. This enhancement
      allow to use wildcard in tiles definition too like the following :

      <definition name="tiles:test.*" path="/testlayout.jsp">
      <put name="testName" value="

      {1}"/>
      <put name="def" value="tiles:another.definition.{1}

      " type="definition"/>
      </definition>

      Using this, you can build a full wildcard request handling when adding a mapping
      in struts-config :

      <action path="/Test*"
      forward="tiles:test.

      {1}

      "/>

      Please note : properties are replaced in attributes of the definition only for
      put elements. It may require a little bit more coding in
      DefinitionsFactory.getDefinition() to add putlist support.

      1. 2.0.5.patch
        8 kB
        Tamas Cserveny
      2. ASF.LICENSE.NOT.GRANTED--patch.txt
        12 kB
        nicolas de loof
      3. ASF.LICENSE.NOT.GRANTED--patch.txt
        2 kB
        nicolas de loof
      4. ASF.LICENSE.NOT.GRANTED--patch.txt
        9 kB
        nicolas de loof
      5. WildcardMatchingDefFactory.java
        6 kB
        Tamas Cserveny

        Issue Links

          Activity

          Hide
          nicolas de loof added a comment -

          Created an attachment (id=12626)
          patch proposal to add wildcard support in tiles-def.xml

          Show
          nicolas de loof added a comment - Created an attachment (id=12626) patch proposal to add wildcard support in tiles-def.xml
          Hide
          nicolas de loof added a comment -

          Created an attachment (id=12628)
          update to userguide documentation

          Show
          nicolas de loof added a comment - Created an attachment (id=12628) update to userguide documentation
          Hide
          nicolas de loof added a comment -

          UPDATE :
          I've added support to list definition attributes and menuItems (new patch
          replaces two ones previously attached to this ticket)

          Following tiles-defs.xml works with wildcards replacements :

          <tiles-definitions>
          <definition name="tiles:base" path="/layout.jsp">
          <put name="base" value="myBase" />
          </definition>

          <definition name="tiles:extends.*" path="/layout.jsp">
          <put name="base" value="base

          {1}" />
          </definition>


          <definition name="tiles:test." extends="tiles:extends.">
          <put name="direct" value="{1}

          " />
          <put name="def" value="tiles:base.

          {1}" type="definition"/>
          <putList name="menu" >
          <item value="1" link="/test/test1.jsp"/>
          <item value="2" link="/test/test2.jsp"/>
          <item value="3" link="/test/numero{1}

          .jsp"/>
          <item value="4" link="/test/

          {1}

          .jsp"/>
          </putList>
          </definition>

          <definition name="tiles:base.1" path="/numberlayout.jsp">
          <put name="direct" value="1" />
          </definition>
          </tiles-definitions>

          Please note :

          wildcards are extracted by re-using code from Action-Mapping wildcard support,
          including special mining of '/' char. For tiles, it may be better to use dot
          ('.') as it is the commonly used separator in tiles names.

          Show
          nicolas de loof added a comment - UPDATE : I've added support to list definition attributes and menuItems (new patch replaces two ones previously attached to this ticket) Following tiles-defs.xml works with wildcards replacements : <tiles-definitions> <definition name="tiles:base" path="/layout.jsp"> <put name="base" value="myBase" /> </definition> <definition name="tiles:extends.*" path="/layout.jsp"> <put name="base" value="base {1}" /> </definition> <definition name="tiles:test. " extends="tiles:extends. "> <put name="direct" value="{1} " /> <put name="def" value="tiles:base. {1}" type="definition"/> <putList name="menu" > <item value="1" link="/test/test1.jsp"/> <item value="2" link="/test/test2.jsp"/> <item value="3" link="/test/numero{1} .jsp"/> <item value="4" link="/test/ {1} .jsp"/> </putList> </definition> <definition name="tiles:base.1" path="/numberlayout.jsp"> <put name="direct" value="1" /> </definition> </tiles-definitions> Please note : wildcards are extracted by re-using code from Action-Mapping wildcard support, including special mining of '/' char. For tiles, it may be better to use dot ('.') as it is the commonly used separator in tiles names.
          Hide
          nicolas de loof added a comment -

          Created an attachment (id=12644)
          new version of the enhancement patch that include support for <putlist> and menuitems

          Show
          nicolas de loof added a comment - Created an attachment (id=12644) new version of the enhancement patch that include support for <putlist> and menuitems
          Hide
          Jamie Paul added a comment -

          At last we have found something on the web that details the use of wildcards in Tiles. Although we are experiencing issues with its success. Below is the struts-config then following is the Tile def with wildcard.

          <action
          path="/*DataEntryList"
          type="mil.usmc.mol.tms.control.

          {1}MemberAction"
          name="{1}

          DataEntryForm"
          scope="session"
          parameter="list" >
          <forward name="success" path="

          {1}DataEntry" />
          </action>

          <definition name="*DataEntry" extends="Layout1" >
          <put name="Title" value="Data Entry" />
          <put name="HelpId" value="19000" />
          <put name="MainNav" value="/WEB-INF/views/tiles/menus/BreadCrum.jsp" />
          <put name="SelectAll" value="/WEB-INF/views/common/SelectAll.jsp" />
          <put name="ContentArea1" value="/WEB-INF/views/common/OccInfo.jsp" />
          <put name="ContentArea2" value="/WEB-INF/views/common/DataEntryOptions.jsp" />
          <put name="ContentArea3" value="/WEB-INF/views/{1}

          /DataEntry.jsp" />
          </definition>

          • the last "(1)" references a folder with proper caps.

          The error that I get when going to this tile is ....

          500 Internal Server Error
          Cannot get request dispatcher for path PFTDataEntry

          In Tiles.def we are using the following DTD...

          <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
          "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">

          We have tried 1.2.7 and 1.3 .dtd without success.

          We are operating with Struts 1.2.7.

          I couldn't find in any Struts documentation the use of wildcards in Tiles.def, is there any?
          Thanks for any help!

          Show
          Jamie Paul added a comment - At last we have found something on the web that details the use of wildcards in Tiles. Although we are experiencing issues with its success. Below is the struts-config then following is the Tile def with wildcard. <action path="/*DataEntryList" type="mil.usmc.mol.tms.control. {1}MemberAction" name="{1} DataEntryForm" scope="session" parameter="list" > <forward name="success" path=" {1}DataEntry" /> </action> <definition name="*DataEntry" extends="Layout1" > <put name="Title" value="Data Entry" /> <put name="HelpId" value="19000" /> <put name="MainNav" value="/WEB-INF/views/tiles/menus/BreadCrum.jsp" /> <put name="SelectAll" value="/WEB-INF/views/common/SelectAll.jsp" /> <put name="ContentArea1" value="/WEB-INF/views/common/OccInfo.jsp" /> <put name="ContentArea2" value="/WEB-INF/views/common/DataEntryOptions.jsp" /> <put name="ContentArea3" value="/WEB-INF/views/{1} /DataEntry.jsp" /> </definition> the last "(1)" references a folder with proper caps. The error that I get when going to this tile is .... 500 Internal Server Error Cannot get request dispatcher for path PFTDataEntry In Tiles.def we are using the following DTD... <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd"> We have tried 1.2.7 and 1.3 .dtd without success. We are operating with Struts 1.2.7. I couldn't find in any Struts documentation the use of wildcards in Tiles.def, is there any? Thanks for any help!
          Hide
          Tamas Cserveny added a comment - - edited

          Hi,

          I've created a similar solution to Tiles 2.0.4. It is not a full solution. I did not try to solve the problem with lists and maps.

          You will only need to specify "org.apache.tiles.definition.DefinitionsFactory" context parameter to use it without a new tiles release.

          Example:
          <definition name=".masterdata.search.*" extends=".mainLayout">
          <put-attribute name="title" value="masterdata.search

          {1}.searchTitle"/>
          <put-attribute name="upper" value="sb.masterdata.search.{1}

          "/>
          </definition>

          Cheers,

          Tamas

          ps. Sorry for the XWork dependency.

          Show
          Tamas Cserveny added a comment - - edited Hi, I've created a similar solution to Tiles 2.0.4. It is not a full solution. I did not try to solve the problem with lists and maps. You will only need to specify "org.apache.tiles.definition.DefinitionsFactory" context parameter to use it without a new tiles release. Example: <definition name=".masterdata.search.*" extends=".mainLayout"> <put-attribute name="title" value="masterdata.search {1}.searchTitle"/> <put-attribute name="upper" value="sb.masterdata.search.{1} "/> </definition> Cheers, Tamas ps. Sorry for the XWork dependency.
          Hide
          Antonio Petrelli added a comment -

          Cserveny
          Can you create a patch for the trunk of SVN repository?
          http://svn.apache.org/repos/asf/tiles/framework/trunk/
          It will become the new "2.1.0" version.

          Thanks

          Show
          Antonio Petrelli added a comment - Cserveny Can you create a patch for the trunk of SVN repository? http://svn.apache.org/repos/asf/tiles/framework/trunk/ It will become the new "2.1.0" version. Thanks
          Hide
          Tamas Cserveny added a comment -

          This is a patch against 641026.

          Maybe we could drop the factory, and just leave the WildcardMatchingDefinitions, thus other factories could take advantage of the wildcard matching.

          Another aspect is, that this factory creates a reference to the XWork package. I can't judge whether this is bad or not.

          Show
          Tamas Cserveny added a comment - This is a patch against 641026. Maybe we could drop the factory, and just leave the WildcardMatchingDefinitions, thus other factories could take advantage of the wildcard matching. Another aspect is, that this factory creates a reference to the XWork package. I can't judge whether this is bad or not.
          Hide
          Antonio Petrelli added a comment -

          It seems like a good job, Cserveny
          But I think that it needs a deeper discussion, can you start a thread at the Tiles Developers list?
          http://tiles.apache.org/mail-lists.html

          Thanks

          Show
          Antonio Petrelli added a comment - It seems like a good job, Cserveny But I think that it needs a deeper discussion, can you start a thread at the Tiles Developers list? http://tiles.apache.org/mail-lists.html Thanks
          Hide
          Antonio Petrelli added a comment -

          It seems that ActionConfigMatcher and WildcardHelper are, in fact, copied from Struts 1, so there is no license issue.

          Show
          Antonio Petrelli added a comment - It seems that ActionConfigMatcher and WildcardHelper are, in fact, copied from Struts 1, so there is no license issue.
          Hide
          Antonio Petrelli added a comment -

          Applied a modified version of the patch submitted by Cserveny Tamás.

          Thanks Cserveny!

          Show
          Antonio Petrelli added a comment - Applied a modified version of the patch submitted by Cserveny Tamás. Thanks Cserveny!
          Hide
          Antonio Petrelli added a comment -

          Closed due to the release of Tiles 2.1.0.

          Show
          Antonio Petrelli added a comment - Closed due to the release of Tiles 2.1.0.

            People

            • Assignee:
              Antonio Petrelli
              Reporter:
              nicolas de loof
            • Votes:
              3 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development