You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marcelo Caldas - CCSC <mc...@ccsc.com> on 2001/12/27 19:11:22 UTC

Nested templates...

Hi,
Is it possible to nest templates?

Like for instance I have template.jsp with:
<template:get name="title"/>
<template:get name="header"/>
<template:get name="sidebar"/>
<template:get name="content"/>

Then I have a listTemplate.jsp like:
<template:insert template="/template.jsp">
        <!-- No template for title here... -->
     <template:put name="header" content="/header.jsp" />
     <template:put name="content" direct="true">
         <template:get name="specificHeader"/>
         <template:get name="dataDisplay"/>
 </template:put>
</template:insert>

Now it's time to use my listTemplate.jsp:
<template:insert template="listTemplate.jsp>
    <template:put name="title" direct="true">Finally my page</template:put>
    <template:put name="specificHeader" content="Area1Header.jsp"/>
    <template:put name="dataDisplay content="myData.jsp"/>
</template:insert>

Right now, I'm receiving the following exception:
java.lang.ClassCastException: org.apache.struts.taglib.template.util.ContentMap

Thanks in advance,
Marcelo.



Re: Nested templates...

Posted by Ted Husted <hu...@apache.org>.
You might want to try Cedric's Tiles library, which is more powerful
than the original template library. 

http://www.lifl.fr/~dumoulin/tiles/

This is also in the contrib folder for the nightly build, though I
believe Cedric will be submitting it to Jakarta Taglibs soon, since it
can be also used outside of Struts. 

Tiles also has a very nifty feature that can render a template
dynamically, and eliminate many of the "wrapper" files. I've used Tiles
my own production applications, and couldn't imagine getting by without
it. Highly recommended.


Marcelo Caldas - CCSC wrote:
> 
> Hi,
> Is it possible to nest templates?
> 
> Like for instance I have template.jsp with:
> <template:get name="title"/>
> <template:get name="header"/>
> <template:get name="sidebar"/>
> <template:get name="content"/>
> 
> Then I have a listTemplate.jsp like:
> <template:insert template="/template.jsp">
>         <!-- No template for title here... -->
>      <template:put name="header" content="/header.jsp" />
>      <template:put name="content" direct="true">
>          <template:get name="specificHeader"/>
>          <template:get name="dataDisplay"/>
>  </template:put>
> </template:insert>
> 
> Now it's time to use my listTemplate.jsp:
> <template:insert template="listTemplate.jsp>
>     <template:put name="title" direct="true">Finally my page</template:put>
>     <template:put name="specificHeader" content="Area1Header.jsp"/>
>     <template:put name="dataDisplay content="myData.jsp"/>
> </template:insert>
> 
> Right now, I'm receiving the following exception:
> java.lang.ClassCastException: org.apache.struts.taglib.template.util.ContentMap
> 
> Thanks in advance,
> Marcelo.

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>