You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael <mi...@idtect.com> on 2002/09/02 15:44:04 UTC
[Tiles] - Definition inheritence question
I've been playing with Tiles for several days, getting some simple
examples to work. I've read all the documentation several times but I'm
missing a key part of the definition inheritence I think. Can somebody
please clarify this for me? Here's what I'd like to do:
I'd like to have a main page that specifies a header, menubar, body, and
footer. Then in the pages of my website, I'd like to insert tiles into
the body. So far it's very easy if I only have one tile to insert into
the body. But I'm really stuck on how to insert two tiles into the same
body. This is what I've tried:
tiles-defs.xml:
<!-- Doc index page description -->
<definition name="default_layout"
path="/jsp/layouts/default_layout.jsp">
<put name="header" value="/jsp/common/header.jsp" />
<put name="menubar" value="/jsp/common/menubar.jsp" />
<put name="footer" value="/jsp/common/footer.jsp" />
</definition>
<definition name="plant_status_page"
extends="default_layout"
path="/jsp/status/plant_status_body.jsp">
<put name="body1" value="plant_list"/>
<put name="body2" value="subsystme_list"/>
</definition>
Default_layout.jsp:
<!-- Header Page Information -->
<tiles:insert attribute="header" />
<!-- Menu Bar -->
<tiles:insert attribute="menubar"/>
<!-- Main Body Information -->
<tiles:insert attribute="body"/>
<!-- Copyright Information -->
<tiles:insert attribute="footer"/>
plant_status_body.jsp:
<HR>TOP<HR>
<!-- Header Page Information -->
<tiles:insert attribute="body1" />
<HR>MIDDLE<HR>
<tiles:insert attribute="body2"/>
<HR>END<HR>
This works, but the problem is I don't get the header & footer defined
in the default_layout.jsp. Now I can cut & paste the header & footer
code into plant_status_body.jsp but I think there has to be a better way
to do this. Can someone please tell me if this is possible and how?
Michael
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [Tiles] - Definition inheritence question
Posted by Cedric Dumoulin <ce...@apache.org>.
Hi Michael,
When you extend a definition, all attributes from ancestor are
inherited, and then overloaded by attributes specified in the new
definition. In your case, you overload the 'path' attribute with a new
value, disguarding the previous value.
The way to go is to have an intermediate tiles (you already have it:
plant_status_body.jsp), and a definition using this tiles. Then you use
the definition as body.
Hope this help,
Cedric
Michael wrote:
>I've been playing with Tiles for several days, getting some simple
>examples to work. I've read all the documentation several times but I'm
>missing a key part of the definition inheritence I think. Can somebody
>please clarify this for me? Here's what I'd like to do:
>
>I'd like to have a main page that specifies a header, menubar, body, and
>footer. Then in the pages of my website, I'd like to insert tiles into
>the body. So far it's very easy if I only have one tile to insert into
>the body. But I'm really stuck on how to insert two tiles into the same
>body. This is what I've tried:
>
>tiles-defs.xml:
>
> <!-- Doc index page description -->
> <definition name="default_layout"
> path="/jsp/layouts/default_layout.jsp">
> <put name="header" value="/jsp/common/header.jsp" />
> <put name="menubar" value="/jsp/common/menubar.jsp" />
> <put name="footer" value="/jsp/common/footer.jsp" />
> </definition>
>
> <definition name="plant_status_page"
> extends="default_layout"
> path="/jsp/status/plant_status_body.jsp">
> <put name="body1" value="plant_list"/>
> <put name="body2" value="subsystme_list"/>
> </definition>
>
>Default_layout.jsp:
>
> <!-- Header Page Information -->
> <tiles:insert attribute="header" />
>
> <!-- Menu Bar -->
> <tiles:insert attribute="menubar"/>
>
> <!-- Main Body Information -->
> <tiles:insert attribute="body"/>
>
> <!-- Copyright Information -->
> <tiles:insert attribute="footer"/>
>
>plant_status_body.jsp:
>
><HR>TOP<HR>
>
> <!-- Header Page Information -->
> <tiles:insert attribute="body1" />
>
><HR>MIDDLE<HR>
>
> <tiles:insert attribute="body2"/>
>
><HR>END<HR>
>
>This works, but the problem is I don't get the header & footer defined
>in the default_layout.jsp. Now I can cut & paste the header & footer
>code into plant_status_body.jsp but I think there has to be a better way
>to do this. Can someone please tell me if this is possible and how?
>
>Michael
>
>
>--
>To unsubscribe, e-mail: <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE : [Tiles] - Definition inheritence question
Posted by Michael <mi...@idtect.com>.
I have found a way to do this using an "intermediate" definition:
<definition name="plant_status_page"
extends="default_layout"
>
<put name="body" value="plant_status_body"/>
</definition>
<definition name="plant_status_body"
extends="default_layout"
path="/jsp/status/plant_status_body.jsp">
</definition>
Plant_status_body.jsp:
<!-- Header Page Information -->
<tiles:insert definition="plant_list" />
<HR>
<tiles:insert definition="subsystem_list"/>
Therefore requesting plant_status_page gives me the page I want. If I
request plant_status_body directly, I don't get the nested behavior that
I'm looking for (my page is missing the header & footer). I'm not sure
this is the cleanest approach, because there seems to be an extra
definition (plant_status_page), but at the same time I'm not sure if
there's a way to avoid it. Is there another way??
Michael
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>