You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Struts Newsgroup (@Basebeans.com)" <st...@basebeans.com> on 2002/06/04 21:40:02 UTC
Tiles and putList
Subject: Tiles and putList
From: "Matt Raible" <ma...@raibledesigns.com>
===
I have the following definition:
<definition name="pageLayout" path="/layouts/pageLayout.jsp">
<putList name="screenStyles">
<add value="/styles/page.css"/>
<add value="/styles/bluegray.css"/>
</putList>
</definition>
Then in my pageLayout.jsp, I use the following to print out the stylesheets
associated with a page:
<style type="text/css" media="screen">
<tiles:useAttribute id="screenList" name="screenStyles"
classname="java.util.List" />
<c:forEach var="stylesheet" items="${screenList}">
@import url(<%=request.getContextPath()%><c:out
value="${stylesheet}"/>);
</c:forEach>
</style>
This all works great. The enhancement I want to make is to define the
different putList's so I can have "blueTheme" and "orangeTheme" as a
definition.
The reason is thus - if I want to override the list of stylesheets in a page
that extends pageLayout, I have to add the full list again, thusly:
<definition name="page.tools" extends="pageLayout">
<put name="title.key" value="tools.title"/>
<put name="heading.key" value="tools.heading"/>
<put name="content" value="/viewer/tools.jsp"/>
<putList name="screenStyles">
<add value="/styles/page.css"/>
<add value="/styles/orangegray.css"/>
</putList>
</definition>
I'd like to have the following:
<definition name="blueTheme">
<putList name="screenStyles">
<add value="/styles/page.css"/>
<add value="/styles/bluegray.css"/>
</putList>
</definition>
and then I could just change the "page.tools" definition to:
<definition name="page.tools" extends="pageLayout">
<put name="title.key" value="tools.title"/>
<put name="heading.key" value="tools.heading"/>
<put name="content" value="/viewer/tools.jsp"/>
<put name="screenStyles" value="blueTheme"/>
</definition>
However, this doesn't work. I'd tell you my error - but since my errorPage
extends pageLayout - I end up in an infinite loop :(
Thanks,
Matt
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Tiles and putList
Posted by Cedric Dumoulin <ce...@lifl.fr>.
Hello,
Actually, definitions are used to associate a layout (page="aLayout.jsp) and
some attributes. Attributes are parameters provided to layout. The Layout can use
its provided attributes as it wants.
What you are trying to do is to use a definition to define a List. Of course
this doesn't work.
A solution is to create a small Tiles that you associate to your definition
blueTheme. This Tiles do the <style type ...> tag using the provided list.
Hope this help,
Cedric
"Struts Newsgroup (@Basebeans.com)" wrote:
> Subject: Tiles and putList
> From: "Matt Raible" <ma...@raibledesigns.com>
> ===
> I have the following definition:
>
> <definition name="pageLayout" path="/layouts/pageLayout.jsp">
> <putList name="screenStyles">
> <add value="/styles/page.css"/>
> <add value="/styles/bluegray.css"/>
> </putList>
> </definition>
>
> Then in my pageLayout.jsp, I use the following to print out the stylesheets
> associated with a page:
>
> <style type="text/css" media="screen">
> <tiles:useAttribute id="screenList" name="screenStyles"
> classname="java.util.List" />
> <c:forEach var="stylesheet" items="${screenList}">
> @import url(<%=request.getContextPath()%><c:out
> value="${stylesheet}"/>);
> </c:forEach>
> </style>
>
> This all works great. The enhancement I want to make is to define the
> different putList's so I can have "blueTheme" and "orangeTheme" as a
> definition.
>
> The reason is thus - if I want to override the list of stylesheets in a page
> that extends pageLayout, I have to add the full list again, thusly:
>
> <definition name="page.tools" extends="pageLayout">
> <put name="title.key" value="tools.title"/>
> <put name="heading.key" value="tools.heading"/>
> <put name="content" value="/viewer/tools.jsp"/>
> <putList name="screenStyles">
> <add value="/styles/page.css"/>
> <add value="/styles/orangegray.css"/>
> </putList>
> </definition>
>
> I'd like to have the following:
>
> <definition name="blueTheme">
> <putList name="screenStyles">
> <add value="/styles/page.css"/>
> <add value="/styles/bluegray.css"/>
> </putList>
> </definition>
>
> and then I could just change the "page.tools" definition to:
>
> <definition name="page.tools" extends="pageLayout">
> <put name="title.key" value="tools.title"/>
> <put name="heading.key" value="tools.heading"/>
> <put name="content" value="/viewer/tools.jsp"/>
> <put name="screenStyles" value="blueTheme"/>
> </definition>
>
> However, this doesn't work. I'd tell you my error - but since my errorPage
> extends pageLayout - I end up in an infinite loop :(
>
> Thanks,
>
> Matt
>
> --
> 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>