For the example you give, the following works just as well in existing
Struts:

In your JSP page:

 <template:insert template="t.jsp">
   <template:put name="pageTitle" direct="true">
      <bean:message key="login.title"/>
   </template:put>
 </template:insert>

 Now, in "t.jsp"....

 <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
 ...
 <h1>Title is <template:get name="pageTitle"/></h1>


Niall


> -----Original Message-----
> From: Dean Wampler [mailto:[EMAIL PROTECTED]]
> Sent: 15 June 2001 01:28
> To: [EMAIL PROTECTED]
> Cc: Dean Wampler (E-mail)
> Subject: Proposal: Support nested tags where only attributes can be used
>
>
> I'm new to struts, so bear with me.
>
> I have been working with the "bean" and "template" tags. I have
> found that a
> straightforward (if a bit tedious to do...) enhancement would make it much
> easier to construct JSP pages in ways useful for me.  Basically, I would
> like to use nested tags to specify some information to outer tag,
> information that currently is specified only through attributes.
>
> Here's an example.  Suppose I have a JSP page that uses the
> <template:insert> construct:
>
> ...
> <%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
> ...
> <template:insert template="t.jsp">
>   <template:put name="pageName" content="login" direct="true"/>
> </template:insert>
>
> Now, in "t.jsp", I would like to use the message tag with the parameter
> "pageName" as a "prefix".  Something that might look like:
>
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> ...
> <h1>Title is <bean:message key='<template:get
> name="pageName"/><%=".title"%>'/></h1>
>
> or perhaps
>
> <h1>Title is <bean:message key='<%=<template:get
> name="pageName"/>+".title"%>'/></h1>
>
> There are two problems: (i) this is ugly and not easy to use by most HTML
> designers, (ii) it doesn't work anyway.  By the time the code
> gets compiled
> to a servlet, it appears that the "key='...'" expression ends up "key=''".
> That is, '<template:get name="pageName"/>' is effectively empty.
>
> However, the following message tag structure would solve both problems and
> support the capability I'm after (indentation is
> for clarity...):
>
> <h1>Title is
>   <bean:message>
>     <bean:key>
>       <template:get name="pageName"/>.title
>     </bean:key>
>   </bean:message>
> </h1>
>
> In other words, support nested tags to specify the "key" and perhaps other
> attributes, so that specifying the values of the attributes is more
> flexible.
>
> Many of the "ant" tasks support capabilities like this and it greatly
> enhances the power and flexibility of build files.
>
> I have looked at the code for MessageTag (and others).  This extension is
> straightforward to implement and it can be done in a backwards compatible
> way (that is, the old attribute syntax will still work fine).
>
> I'm willing to implement the changes, but before I do so, I
> wanted to check
> with the rest of you to see if there are any good reasons not to proceed.
>
> Thanks,
> dean
>
> Dean Wampler, Ph.D.
> [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
> http://www.powerhousetechnology.com/
>
> I want my tombstone to say:
>
>   Unknown Application Error in Dean Wampler.exe.
>   Application Terminated.
>                                                  [OK] [Cancel]
>

Reply via email to