tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rs...@vgalleries.com (Richard Sand)
Subject is it possible to use a tag that defines a scripting variable multiple times in a page?
Date Thu, 12 Oct 2000 00:06:04 GMT
Hi all,

I'm trying to write a tag that uses a bean that I've written.  I want the tag to look for
the bean in the page context, and if its not there, make one and add it to the page.  I want
to be able to use the tag in multiple places, and use the bean it creates elsewhere in the
page.

But this last requirement seems to be a hitch.  i.e., consider the following in a jsp page:

<mytags:tag1/>           // this tag creates a bean with an id=mybean
stuff.....
<mytags:tag1/>          // this bean sees that id=mybean already exists and reuses it
more stuff......
<% if (mybean.somemethod() == true {....         // this code snippet uses mybean

Is this possible? If I write a TEI that defines mybean and has declare=true, then I get a
compile error because mybean is defined twice.  If I have it set to false, I get an error
for it being undeclared, even with only a single use of mytags and no references to mybean.

Am I missing something?  Can someone tell me how this can work?  Is there a way to tell a
JSP page that this tag will: "declare a variable if its not already declared in the page"

Thanks!

-Richard

Mime
View raw message