tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kees Jongenburger <ke...@netlinq.nl>
Subject Re: is it possible to use a tag that defines a scripting variable multiple times in a page?
Date Thu, 12 Oct 2000 07:32:56 GMT
hi,
i think typical use to get a Bean from a taglib  is like this:

Object o = pageContext.getAttribute("mybean", pageContext.SESSION_SCOPE);
(((MyBean)o).somemethod()){



-- 
Kees Jongenburger
Java developer               E-mail keesj@framfab.nl
NetlinQ Framfab              Phone  +31 (0)20 607 75 00
http://www.netlinq.nl/       Fax    +31 (0)20 607 75 01
http://www.framfab.com/      Mobile +31 (0)6 2000 29 18


On Wed, 11 Oct 2000, Richard Sand wrote:

> 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