You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ro...@shell.ca on 2001/02/16 17:30:04 UTC

Variable substitution in template tags

Hello Everyone,  

I am a brand new user; only subscribed about 15 minutes ago.

My team is doing some preliminary investigations into the use of struts
for rendering jsp-based browser pages.  I took a close look at the
struts-template sample application, and we are okay with setting our
template header and sections using put and get statements.  However, we
have added an extra dimension to it in which we actually pick up
different template headers depending on our user's locale, and then we
define specific template file names in resource bundle properties files.

Based on our structure, we need to do a VARIABLE (or properties key)
SUBSTITUTION, as follows:

<template:insert template='<bean:message key="templateName.JSP"/>' />

Or variable substitution as follows:
<template:insert template='<%= somePreviouslyDefinedVariableName %>' />

We do the same for puts and gets, etc, thereby nesting bean tags in
template tags.  We have of course include the struts-bean.tld file in
our taglib declarations, as well as defined our Resource Application
parameter in web.xml. Tomcat squeaks when we perform this variable
substitution or nested tags.

Is this allowed?  Can anyone please give us directions, recommendations
as to how to go about substitution in struts tags generally?   

Thanks a lot!


Rose Joshua
Information and Computing / eBusiness Unit
Shell Canada Limited
Calgary, Alberta.  
Telephone:  (403)-691-4527
email: <ro...@shell.ca>


Re: REQUEST for Multi-part form EXAMPLE

Posted by David Winterfeldt <dw...@yahoo.com>.
There is a simple multi-part form example in the WAR
example on my site.  It has validation in it though,
but that would be easy to remove.  The example is
using request scope and hidden fields to hold the
information from the last form.

David Winterfeldt
http://home.earthlink.net/~dwinterfeldt/

--- Rob Leland <Ro...@freetocreate.org> wrote:
> Does anyone have an example of a multi-part form
> they would like to 
> donate to the struts example library ?
> 
> -Rob


__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

REQUEST for Multi-part form EXAMPLE

Posted by Rob Leland <Ro...@freetocreate.org>.
Does anyone have an example of a multi-part form they would like to 
donate to the struts example library ?

-Rob

Re: Variable substitution in template tags

Posted by Craig Tataryn <Cr...@msdw.com>.
Hey Rose, glad to see you joined the list!  There was just a posting
yesterday that addressed a similar problem where a person wanted to add a
Resource message as the value the "alt" attribute of the html:img but could
nest the <bean:message/> tag.

The answer I gave is below, try it out and see if it works:

==============================================
How about this:

<!-- MyResources would be replaced with whatever class name you used in the
application init-param you setup for the ActionServlet
-->
<jsp:useBean id="resouces" class="MyResources" />

<html:img src="someImage.png" alt='<%=
resources.getString("someImage.alt.text")
%>'/>

Craig T.

Peter Alfors wrote:

> scratch that.  You would need to have a bean that had access to the
messages.
>
> Peter Alfors wrote:
>
> > I think that <bean:define>  does what you want.
> >
> > <bean:define id="altTxt" property="someImage.alt.text"/>
> > <html:img src="someImage.png" alt="<%= altTxt %>"/>
> >
> > HTH,
> >     Pete
> >
> > Howard Moore wrote:
> >
> > > Can anybody suggest how I can add internationalised alt text to the
> > > <html:img> tag?
> > >
> > > If it were legal I would like to do something like the following;
> > >
> > > <html:img src="someImage.png" alt="<bean:message
> > > key='someImage.alt.text'/>"/>
> > >
> > > but you can't nest tags like this.
> > >
> > > If not does anybody think it would be useful to add an optional 'id'
> > > attribute to the <bean:message> tag which, if set, causes the
translated
> > > message to be stored in a page context bean with the given name rather
than
> > > being written out? This would allow me to write something like;
> > >
> > > <bean:message id="altTxt" key="someImage.alt.text"/>
> > > <html:img src="someImage.png" alt="<%= altTxt %>"/>
> > >
> > > It would also allow translated strings to be cached in the page if
they are
> > > going to be used repeatedly (inside a <logic:iterate> tag, for
example).
> > > This may improve performance considerably.
> > >
> > > Any comments?
> > >
> > > -------------------------------------------
> > > Howard Moore
> > > Senior Software Engineer
> > > Datapulse CTI
> > > Tel : +44 (0)1491 418000
> > > Fax : +44 (0)1491 411459
> > > E-mail: Howard.Moore@datapulse.com

--
I've been trying to change the world for years, but they just won't give me
the
source code....

Rose.Joshua@shell.ca wrote:

> Hello Everyone,
>
> I am a brand new user; only subscribed about 15 minutes ago.
>
> My team is doing some preliminary investigations into the use of struts
> for rendering jsp-based browser pages.  I took a close look at the
> struts-template sample application, and we are okay with setting our
> template header and sections using put and get statements.  However, we
> have added an extra dimension to it in which we actually pick up
> different template headers depending on our user's locale, and then we
> define specific template file names in resource bundle properties files.
>
> Based on our structure, we need to do a VARIABLE (or properties key)
> SUBSTITUTION, as follows:
>
> <template:insert template='<bean:message key="templateName.JSP"/>' />
>
> Or variable substitution as follows:
> <template:insert template='<%= somePreviouslyDefinedVariableName %>' />
>
> We do the same for puts and gets, etc, thereby nesting bean tags in
> template tags.  We have of course include the struts-bean.tld file in
> our taglib declarations, as well as defined our Resource Application
> parameter in web.xml. Tomcat squeaks when we perform this variable
> substitution or nested tags.
>
> Is this allowed?  Can anyone please give us directions, recommendations
> as to how to go about substitution in struts tags generally?
>
> Thanks a lot!
>
> Rose Joshua
> Information and Computing / eBusiness Unit
> Shell Canada Limited
> Calgary, Alberta.
> Telephone:  (403)-691-4527
> email: <ro...@shell.ca>

--
I've been trying to change the world for years, but they just won't give me
the source code....