You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by PhilNoon <ph...@hotmail.com> on 2003/10/09 18:29:50 UTC

tiles-defs.xml and dynamic page titles: how to do?

I am using tiles. I define the title of a web page in tiles-defs.xml as in
this snippet:

  <definition name="tiles.customer.title.parcels"
extends="tiles.default.layout">
    <put name="title"     value="Customer Consignment Note"/>
    <put name="content"   value="/pages/customerTitleParcels.jsp"/>
  </definition>

Then in my jsp, I have:

  <tiles:getAsString name="title"/>

Which outputs "Customer Consignment Note" as expected.

Now my client wants the title to read "Consignment Note for XXXX" where xxxx
is the customer's name.

Does anyone have an idea how to do this?




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: tiles-defs.xml and dynamic page titles: how to do?

Posted by Kris Schneider <kr...@dotech.com>.
I've never used Tiles, but one approach would be to put the title in a
properties file:

parcelsTitle=Consignment Note for {0}

Then set up a Tiles attribute to hold the key for the title message. I guess it
would look something like:

<definition name="tiles.customer.title.parcels"
            extends="tiles.default.layout">
  <put name="titleKey" value="parcelsTitle"/>
  <put name="content" value="/pages/customerTitleParcels.jsp"/>
</definition>

Then create a scoped variable to hold the key (not sure if this is right):

<tiles:importAttribute name="titleKey"/>

Finally, use <bean:message> with the key and dynamic customer name:

<jsp:useBean id="customerName" type="java.lang.String"/>
<bean:message name="titleKey" arg0="<%= customerName %>"/>

Or:

<bean-el:message name="titleKey" arg0="${customerName}"/>

Quoting Kirk Wylie <kw...@m7.com>:

> Have you thought about putting the customer name into request scope in 
> your actions and using some type of expression (perhaps using struts-el 
> or JSTL) to write out the title? So, for example, you'd have something 
> roughly (forgive the fact that I'm not doing it in el):
> 
> <% pageTitle = "%><bean.write name="titleFromTiles"><%, " + customerName;
> %>
> <title><%=pageTitle%></title>
> 
> So rather than putting the actual final title into the page, you'd put 
> in a pattern, and rely on the individual tiles to actually compose the 
> page title out of the tiles attribute.
> 
> Does that make any sense?
> 
> Kirk Wylie
> M7 Corporation
> 
> PhilNoon wrote:
> > I am using tiles. I define the title of a web page in tiles-defs.xml as
> in
> > this snippet:
> > 
> >   <definition name="tiles.customer.title.parcels"
> > extends="tiles.default.layout">
> >     <put name="title"     value="Customer Consignment Note"/>
> >     <put name="content"   value="/pages/customerTitleParcels.jsp"/>
> >   </definition>
> > 
> > Then in my jsp, I have:
> > 
> >   <tiles:getAsString name="title"/>
> > 
> > Which outputs "Customer Consignment Note" as expected.
> > 
> > Now my client wants the title to read "Consignment Note for XXXX" where 
> > xxxx
> > is the customer's name.
> > 
> > Does anyone have an idea how to do this?

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: tiles-defs.xml and dynamic page titles: how to do?

Posted by Kirk Wylie <kw...@m7.com>.
Have you thought about putting the customer name into request scope in 
your actions and using some type of expression (perhaps using struts-el 
or JSTL) to write out the title? So, for example, you'd have something 
roughly (forgive the fact that I'm not doing it in el):

<% pageTitle = "%><bean.write name="titleFromTiles"><%, " + customerName; %>
<title><%=pageTitle%></title>

So rather than putting the actual final title into the page, you'd put 
in a pattern, and rely on the individual tiles to actually compose the 
page title out of the tiles attribute.

Does that make any sense?

Kirk Wylie
M7 Corporation

PhilNoon wrote:
> I am using tiles. I define the title of a web page in tiles-defs.xml as in
> this snippet:
> 
>   <definition name="tiles.customer.title.parcels"
> extends="tiles.default.layout">
>     <put name="title"     value="Customer Consignment Note"/>
>     <put name="content"   value="/pages/customerTitleParcels.jsp"/>
>   </definition>
> 
> Then in my jsp, I have:
> 
>   <tiles:getAsString name="title"/>
> 
> Which outputs "Customer Consignment Note" as expected.
> 
> Now my client wants the title to read "Consignment Note for XXXX" where 
> xxxx
> is the customer's name.
> 
> Does anyone have an idea how to do this?
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org