I've posted a similar question to this today - I'm trying to use
<tiles:getAsString name="??"/> in a 'header.jsp', but keep getting the
following message:

[ServletException in:/WEB-INF/tiles/layouts/header.jsp] Error -
tag.getAsString : attribute 'function' not found in context. Check tag
syntax' 

I've assumed that it is because the header is an 'included' file.  Is
Michael's solution the right way to do this?

Jerry

-----Original Message-----
From: Michael Connor [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 10, 2002 1:24 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Tiles: pass "title" value to header page


I think I know what your issue is here because I had a problem with this a
couple of days ago.  When I went to use the title attribute in the header,
it was null.  I had to do this in my basicLayout page...

<tiles:useAttribute name="title" classname="java.lang.String"
ignore="true"/>

<tiles:insert attribute="header">
   <tiles:put name="title" value="<%=title%>"/>
</tiles:insert>    

It didn't really make sense to me why the title attribute didn't trickle
down into the header.  It seems like a scope issue and I was trying
different ways of declaring scope but didn't have any luck.  This is the
only way I could get it to work.

Michael Connor

-----Original Message-----
From: James Mitchell [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 10, 2002 2:30 AM
To: Struts Users Mailing List
Subject: RE: Tiles: pass "title" value to header page


> -----Original Message-----
> From: David M. Karr [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 09, 2002 8:47 PM
> To: [EMAIL PROTECTED]
> Subject: Tiles: pass "title" value to header page
>
>
> I have a simple page definition that looks like this:
>
> --------------
> <tiles:insert page="basicLayout.jsp">
>  <tiles:put name="title" value="Music Index Home"/>
>  <tiles:put name="header" value="header.jsp"/>
>  <tiles:put name="footer" value="footer.jsp"/>
>  <tiles:put name="sidebar" value="menu.jsp"/>
>  <tiles:put name="body" value="mainBody.jsp"/>
> </tiles:insert>
> --------------
>
> I'm thinking that it might be good to code "header.jsp" so it
> shows the "title"
> string, by reference, instead of hard-coded, so I don't have to
> write it twice,

What would you have twice?  The tiles:put or the tiles:getAsString?
Why not just define the title in the ApplicationResources.properties file?

> in two different places.  I would have to somehow "pass" the
> value provided for
> the "title" attribute to "header.jsp" so it can read it as a
> request attribute,
> possibly.
>
> What are the various ways I could achieve this (hopefully without using
> scriptlets)?  Is this a reasonable thing to do?

It's not clear (to me) what you want to do.
Off-hand (and if I am guess-timating correctly) I can think of about 10
unique ways to avoid duplication of code (or in this case, tiles
configuration)

>
> If I could send "request parameters" or "attributes" with
> "tiles:insert", then
> with my "tiles:insert" tag for the "header" attribute, I could
> pass the output
> of "tiles:getAsString" to get the "title" field.  I don't know if this is
> possible, however.

In concept, you would only want to do this if you wanted a different title
for each view.

I can provide (very basic) code samples for what I consider to be "Best
Practices with Tiles".  Let me know if you would like a copy.

>
> --
> ===================================================================
> David M. Karr          ; Java/J2EE/XML/Unix/C++
> [EMAIL PROTECTED]
>


James Mitchell
Software Engineer\Struts Evangelist
Struts-Atlanta, the "Open Minded Developer Network"
http://www.open-tools.org/struts-atlanta







This transmission (and any information attached to it) may be confidential and is 
intended solely for the use of the individual or entity to which it is addressed. If 
you are not the intended recipient or the person responsible for delivering the 
transmission to the intended recipient, be advised that you have received this 
transmission in error and that any use, dissemination, forwarding, printing, or 
copying of this information is strictly prohibited. If you have received this 
transmission in error, please immediately notify LabOne at (800)388-4675.



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to