You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Adam Hardy <ah...@cyberspaceroad.com> on 2007/09/03 19:43:52 UTC

context of parameters

I have created a layout JSP to use as a template for an abstract layout 
definition. I extend it with my concrete definition, for example (simplified):

<definition name="layout.tile" template="layout.jsp">
   <put-attribute name="headerTile" type="template" value="header.jsp" />
   <put-attribute name="menuTile" type="template" value="menu.jsp" />
</definition>
<definition name="categoryList.tile" extends="layout.tile">
   <put-attribute name="bodyContentTile" value="categoryList.jsp" />
   <put-attribute name="title" value="category.list.pageHeader" />
   <put-attribute name="subMenuTile" value="submenu.jsp" />
</definition>

The "title" attribute varies between concrete definitions. Unless I declare the 
"title" attribute again in the layout template, the header tile and header.jsp 
cannot see it, like this:


<tiles:importAttribute />
<body>
   <div id="container">
     <div id="header">
       <tiles:insertAttribute name="headerTile">
         <tiles:putAttribute name="title" value="${title}" />
       </tiles:insertAttribute>
     </div>
     <div id="content">
       <tiles:insertAttribute name="bodyContentTile"/>
     </div>
     <div id="subMenu">
       <div class="subMenu">
         <tiles:insertAttribute name="subMenuTile"/>
       </div>
     </div>
   </div>
</body>

Is this the right way to do it or is there a more elegant way?

I know that once this prototype goes into development, there will be many more 
attributes defined in the concrete definition but used in other tile templates. 
I would be glad to find out whether there is an automatic way of putting these 
attributes into the context of the pages where I need them?

I have looked hard at the possibility of 'nesting' the definitions, but that 
doesn't seem to be the solution, or at least it would be no more elegant than 
the above.

Thanks
Adam


Re: context of parameters

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
Antonio Petrelli on 03/09/07 19:09, wrote:
> 2007/9/3, Adam Hardy <ah...@cyberspaceroad.com>:
>> I have created a layout JSP to use as a template for an abstract layout
>> definition. I extend it with my concrete definition, for example (simplified):
>>
>> <definition name="layout.tile" template="layout.jsp">
>>    <put-attribute name="headerTile" type="template" value="header.jsp" />
>>    <put-attribute name="menuTile" type="template" value="menu.jsp" />
>> </definition>
>> <definition name="categoryList.tile" extends="layout.tile">
>>    <put-attribute name="bodyContentTile" value="categoryList.jsp" />
>>    <put-attribute name="title" value="category.list.pageHeader" />
>>    <put-attribute name="subMenuTile" value="submenu.jsp" />
>> </definition>
>>
>> The "title" attribute varies between concrete definitions. Unless I declare the
>> "title" attribute again in the layout template, the header tile and header.jsp
>> cannot see it, like this:
>>
>>
>> <tiles:importAttribute />
>> <body>
>>    <div id="container">
>>      <div id="header">
>>        <tiles:insertAttribute name="headerTile">
>>          <tiles:putAttribute name="title" value="${title}" />
>>        </tiles:insertAttribute>
>>      </div>
>>      <div id="content">
>>        <tiles:insertAttribute name="bodyContentTile"/>
>>      </div>
>>      <div id="subMenu">
>>        <div class="subMenu">
>>          <tiles:insertAttribute name="subMenuTile"/>
>>        </div>
>>      </div>
>>    </div>
>> </body>
>>
>> Is this the right way to do it or is there a more elegant way?
>>
>> I know that once this prototype goes into development, there will be many more
>> attributes defined in the concrete definition but used in other tile templates.
>> I would be glad to find out whether there is an automatic way of putting these
>> attributes into the context of the pages where I need them?
>>
>> I have looked hard at the possibility of 'nesting' the definitions, but that
>> doesn't seem to be the solution, or at least it would be no more elegant than
>> the above.
> 
> Currently there is no support for the so-called "pass-through" attributes. See:
> http://tiles.apache.org/faq.html#pass-thru
> Anyway I opened an issue for this, since you are not alone:
> https://issues.apache.org/struts/browse/TILES-208
> Notice that, eventually, it will be implemented in Tiles 2.1
> 
> If you want a ready-to-use solution, check out again the preparer: you
> could add a request-scoped attribute that is visible across the entire
> request/response.

Thank alot, Antonio.

I will certainly look into the Preparer.


All the best
Adam

Re: context of parameters

Posted by Antonio Petrelli <an...@gmail.com>.
2007/9/3, Adam Hardy <ah...@cyberspaceroad.com>:
> I have created a layout JSP to use as a template for an abstract layout
> definition. I extend it with my concrete definition, for example (simplified):
>
> <definition name="layout.tile" template="layout.jsp">
>    <put-attribute name="headerTile" type="template" value="header.jsp" />
>    <put-attribute name="menuTile" type="template" value="menu.jsp" />
> </definition>
> <definition name="categoryList.tile" extends="layout.tile">
>    <put-attribute name="bodyContentTile" value="categoryList.jsp" />
>    <put-attribute name="title" value="category.list.pageHeader" />
>    <put-attribute name="subMenuTile" value="submenu.jsp" />
> </definition>
>
> The "title" attribute varies between concrete definitions. Unless I declare the
> "title" attribute again in the layout template, the header tile and header.jsp
> cannot see it, like this:
>
>
> <tiles:importAttribute />
> <body>
>    <div id="container">
>      <div id="header">
>        <tiles:insertAttribute name="headerTile">
>          <tiles:putAttribute name="title" value="${title}" />
>        </tiles:insertAttribute>
>      </div>
>      <div id="content">
>        <tiles:insertAttribute name="bodyContentTile"/>
>      </div>
>      <div id="subMenu">
>        <div class="subMenu">
>          <tiles:insertAttribute name="subMenuTile"/>
>        </div>
>      </div>
>    </div>
> </body>
>
> Is this the right way to do it or is there a more elegant way?
>
> I know that once this prototype goes into development, there will be many more
> attributes defined in the concrete definition but used in other tile templates.
> I would be glad to find out whether there is an automatic way of putting these
> attributes into the context of the pages where I need them?
>
> I have looked hard at the possibility of 'nesting' the definitions, but that
> doesn't seem to be the solution, or at least it would be no more elegant than
> the above.

Currently there is no support for the so-called "pass-through" attributes. See:
http://tiles.apache.org/faq.html#pass-thru
Anyway I opened an issue for this, since you are not alone:
https://issues.apache.org/struts/browse/TILES-208
Notice that, eventually, it will be implemented in Tiles 2.1

If you want a ready-to-use solution, check out again the preparer: you
could add a request-scoped attribute that is visible across the entire
request/response.

Antonio

Antonio