You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Richards <gr...@cyber4.org> on 2001/06/10 07:16:18 UTC

template:put and get

I've got a situation where I want to include a header file with

<template:insert template="/share/inc_header.jsp">
    <template:put name="header_image" content="/media/h_modify.gif" direct="true"/>
</template:insert>

and then in the header file have

	<html:img page="/media/h_modify.gif" width="315" height="23" border="0"/>

but replace the page="" with the <template:get/>. Trouble is you can't nest 
tags. One options is to do the html without the jsp, and have

	<img src="<%= request.getContextPath() %>/media/h_modify.gif" width="315" height="23" border="0"/>

but that doesn't look great, but I can't think of anything else. The <template:put/>
seems to hide the content away somewhere away in the request, and I don't want to
create 20 little html/jsp pages for the different headers that I have.

Any ideas?



--
Kumera - a new Open Source Content Management System
for small to medium web sites written in Perl and using XML
http://www.cyber4.org/kumera/index.html

Re[2]: template:put and get

Posted by Oleg V Alexeev <go...@penza.net>.
Hello Jim,

Sunday, June 10, 2001, 8:27:25 PM, you wrote:


JR> I decided to do the second option, it works quite well. I don't like the
JR> idea of putting the while <html:img/> tag into the <template:put/> because
JR> that'd make the template file confusing for someone trying to maintain it
JR> (the image tag would never appear in the source for the included file, the
JR> developer could spend ages trying to work out what's going on)

So far we have access to the values of template placeholders only via
template:get. You can write your own tag to define registered
template placeholders as page scope beans and
access such values via bean:write tags or use it in html:img tag. I
think it will be good template mechanism enhanesment.

-- 
Best regards,
 Oleg                            mailto:gonza@penza.net



Re: template:put and get

Posted by Jim Richards <gr...@cyber4.org>.
I decided to do the second option, it works quite well. I don't like the
idea of putting the while <html:img/> tag into the <template:put/> because
that'd make the template file confusing for someone trying to maintain it
(the image tag would never appear in the source for the included file, the
developer could spend ages trying to work out what's going on)

>JR> but replace the page="" with the <template:get/>. Trouble is you can't nest 
>JR> tags. One options is to do the html without the jsp, and have
>
>JR>         <img src="<%= request.getContextPath() %>/media/h_modify.gif" width="315" height="23" border="0"/>
>
>JR> but that doesn't look great, but I can't think of anything else. The <template:put/>
>JR> seems to hide the content away somewhere away in the request, and I don't want to
>JR> create 20 little html/jsp pages for the different headers that I have.
>
>JR> Any ideas?
>
>You can place whole html:img tag to the template:put tag as its
>content and cut content and direct attributes.

--
Kumera - a new Open Source Content Management System
for small to medium web sites written in Perl and using XML
http://www.cyber4.org/kumera/index.html

Re: template:put and get

Posted by Oleg V Alexeev <go...@penza.net>.
Hello Jim,

Sunday, June 10, 2001, 9:16:18 AM, you wrote:


JR> I've got a situation where I want to include a header file with

JR> <template:insert template="/share/inc_header.jsp">
JR>     <template:put name="header_image" content="/media/h_modify.gif" direct="true"/>
JR> </template:insert>

JR> and then in the header file have

JR>         <html:img page="/media/h_modify.gif" width="315" height="23" border="0"/>

JR> but replace the page="" with the <template:get/>. Trouble is you can't nest 
JR> tags. One options is to do the html without the jsp, and have

JR>         <img src="<%= request.getContextPath() %>/media/h_modify.gif" width="315" height="23" border="0"/>

JR> but that doesn't look great, but I can't think of anything else. The <template:put/>
JR> seems to hide the content away somewhere away in the request, and I don't want to
JR> create 20 little html/jsp pages for the different headers that I have.

JR> Any ideas?

You can place whole html:img tag to the template:put tag as its
content and cut content and direct attributes.

-- 
Best regards,
 Oleg                            mailto:gonza@penza.net



Re: template:put and get

Posted by suhas <su...@techmas.hcltech.com>.
I think <template:put> tag puts the contents (="/media/h_modify.gif)in some
hashtable on the stack . and <template:get> tag retrieves that content from
hashtable and includes in the pageContext which displays it . so I think u
can put anything in the header.jsp

Suhas
----- Original Message -----
From: Jim Richards <gr...@cyber4.org>
To: <st...@jakarta.apache.org>
Sent: Sunday, June 10, 2001 6:16 AM
Subject: template:put and get


>
> I've got a situation where I want to include a header file with
>
> <template:insert template="/share/inc_header.jsp">
>     <template:put name="header_image" content="/media/h_modify.gif"
direct="true"/>
> </template:insert>
>
> and then in the header file have
>
> <html:img page="/media/h_modify.gif" width="315" height="23" border="0"/>
>
> but replace the page="" with the <template:get/>. Trouble is you can't
nest
> tags. One options is to do the html without the jsp, and have
>
> <img src="<%= request.getContextPath() %>/media/h_modify.gif" width="315"
height="23" border="0"/>
>
> but that doesn't look great, but I can't think of anything else. The
<template:put/>
> seems to hide the content away somewhere away in the request, and I don't
want to
> create 20 little html/jsp pages for the different headers that I have.
>
> Any ideas?
>
>
>
> --
> Kumera - a new Open Source Content Management System
> for small to medium web sites written in Perl and using XML
> http://www.cyber4.org/kumera/index.html