apachetiles-3

Nested Tiles with Wildcard Support


Tile configuration :


<definition name="*/*/*/*/*/index" extends="defaultLayout.{1}.{2}.{4}">
    <put-attribute name="headerLocationPart" >
    <definition name="indexLocation"  template="/{1}/{2}/mkportal/s/layouts/LocationLayout.jsp">
        <put-attribute name="location" value="/{1}/{2}/mkportal/s/location.jsp" />
        <put-attribute name="subscriptionBtn" value="/{1}/{2}/mkportal/s/subscriptionBtn.jsp" />
        <put-attribute name="indexPromo" value="/{1}/{2}/mkportal/s/indexPromo.jsp" />
        </definition>
  </put-attribute>
    <put-attribute name="body" value="/{1}/{2}/mkportal/s/index.jsp" />
</definition>

When I m going to hit URL from my browser

http://localhost:8080/etisalat/wap/mkportal/s/index.wfv

problem is Nested Definition "indexLocation" does not resolve {1},{2} parameter .


Error is


org.apache.tiles.impl.CannotRenderException: JSPException including path '/{1}/{2}/mkportal/s/layouts/LocationLayout.jsp'.

So I need solution to pass wildcard value to resolve nested tile definition.


Solution

  • Anonymous definitions can't have wildcards because they don't have names.

    There is 2 different approaches you might take here (i don't know which is correct for you because i don't know exactly what you are doing)

    1) You can use cascading="true" attributes instead of the additional definition like…

    <definition name="*/*/*/*/*/index" extends="defaultLayout.{1}.{2}.{4}">
        <put-attribute name="headerLocationPart" template="/{1}/{2}/mkportal/s/layouts/LocationLayout.jsp"/>
        <put-attribute name="location" value="/{1}/{2}/mkportal/s/location.jsp" cascade="true"/>
        <put-attribute name="subscriptionBtn" value="/{1}/{2}/mkportal/s/subscriptionBtn.jsp" cascade="true"/>
        <put-attribute name="indexPromo" value="/{1}/{2}/mkportal/s/indexPromo.jsp" cascade="true"/>
        <put-attribute name="body" value="/{1}/{2}/mkportal/s/index.jsp" />
    </definition>
    

    2) You can use a named definition like…

        <definition name="indexLocation.*.*"  template="/{1}/{2}/mkportal/s/layouts/LocationLayout.jsp">
            <put-attribute name="location" value="/{1}/{2}/mkportal/s/location.jsp" />
            <put-attribute name="subscriptionBtn" value="/{1}/{2}/mkportal/s/subscriptionBtn.jsp" />
            <put-attribute name="indexPromo" value="/{1}/{2}/mkportal/s/indexPromo.jsp" />
        </definition>
    
    <definition name="*/*/*/*/*/index" extends="defaultLayout.{1}.{2}.{4}">
        <put-attribute name="headerLocationPart" value="indexLocation.{1}.{2}"/>
        <put-attribute name="body" value="/{1}/{2}/mkportal/s/index.jsp" />
    </definition>
    

    Reference: http://tiles.apache.org/framework/tutorial/advanced/nesting-extending.html