You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by Eduardo Pelegri-Llopart <Ed...@Sun.COM> on 2001/05/01 22:01:01 UTC

suggestion: "with" tag -- Re: A bit of newbie question

Here are two ideas...

 <x:with name="x" value="y"> Here you can say <%= x %> and you get 'y'
</x:with>
and

<x:set name="x">VALUE</x:set>
here you can say <%= x %>


***********************


When I started writing this I was expecting to be able to write more
sophisticated tags,  for example, I wanted to say:

 <x:body name="x">
   <x:value>anything goes</x:value>
   <x:body> here you can say <%= x %> and get the result of evaluating
'anything goes'
   </x:body>
 </x:with>

or
 <x:body name="x">
   <x:value>anything goes</x:value>
   here you can say <%= x %> and get the result of the evaluation
 </x:body>

or
 <x:block>
   <x:set name="x">VALUE</x:set>
   here you can use <%= x %>
 <x:block>
 here you cannot say <%= x %>

etc...

Unfortunately, none of these seem possible in JSP 1.2 because, although
JSP 1.2 extended the notion of validation to include PageData
information, scripting variable is still only available through
TagExtraInfo.getVariableInfo(TagData), and there is no new method that
uses PageData.

Private communication between the tags is possible, of course.  The
problem is the scripting variable use.

I'll bring up the getVariableInfo(PageData) issue to the JSR-053
experts, although it is late enough that I don't know if this can be
fixed for JSP 1.2.

	- eduard/o

James Strachan wrote:
> 
> ----- Original Message -----
> From: "Peter Giannopoulos" <Pe...@gemplus.com>
> To: <ta...@jakarta.apache.org>
> Sent: Thursday, April 26, 2001 7:49 PM
> Subject: A bit of newbie question
> 
> > Hello all,
> >
> > I am new to the taglib development world so please bare with me, if I
> > sometimes seem to ask silly questions. :-)
> >
> > That being said, I would love to know if there is a way to use a custom
> tag
> > within another custom tag (as an attribute value)
> >
> > For example something like (please let me know if I'm being stupid
> here...is
> > there a better way?)
> >
> > <foo:bar attrib1="baz" attrib2=" <foo:othertag attrib1=""> " />
> > OR
> >
> > <foo:bar attrib1="baz" attrib2="<%=somevalue%>"> " />
> >    ----> I really would rather avoid any code between <% and %> on the jsp
> > page.
> 
> If <foo:bar> isn't a JSP custom tag then this isn't an issue at all. If it
> is then how about
> 
> <foo:bar attrib1="baz">
>     <foo:othertag attrib1="">
> </foo:bar>
> 
> Then in the OtherTag class can communicate implicitly with its parent tag to
> set the required attribute(s).
> It can have code along the lines of
> 
> public class OuterTag extends TagSupport {
> 
> public int doEndTag()
> 
>     Tag parent = getParent();
>     if ( parent instanceof FooTag ) {
>         FooTag foo = (FooTag) parent;
>         foo.setAttribute2( someValue );
>     }
>     ...
> }
> 
> If you go down this route be careful to make sure most of the 'action' code
> of the <foo:bar> and <foo:othertag> tags are in the doEndTag() methods
> rather than the doStartTag() methods so that the tags have time to initalise
> themselves first, via containment.
> 
> James
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com