Hi all. I'm trying to write my own tags and having a few problems. They are kind of similar to the struts logic:iterate tag. The outer one extends javax.servlet.jsp.tagext.IterationTag. The will be used like this: <john uter id="currentBook" collection="books" type="org.john.Book" > <john:inner value='<%= currentBean.getBookTitle() %>' /> </john uter> Within the code for the john uter tag it gets the collection 'books' out of the request scope (other stuff has put it there). Now, as it iterates it stores each Book from the collection in PageContext.setAttribute. However, this does not work. It appears that the inner tag cannot identify this reference 'currentBean' and thus does not compile properly at request time. However THIS works: <john uter id="currentBook" collection="books" type="org.john.Book" > <%= currentBean.getBookTitle() %> </john uter> Can someone explain the issue here? Why does a nested tag not have access to attributes set by outer tags? thanks! john [ January 02, 2004: Message edited by: John Summers ]
John, if you click the 'disable smilies' checkbox on your posts, the colons in your tags won't get converted. Secondly, I'm not completely sure that I understand your issue. You say that the inner tag does not 'see' currentBean, but you don't describe how this is being set or retrieved. An inner tag will have access to the page context, so attributes set by the outer tag will be available to an inner tag if set in the start method of the outer tag. bear
Ah!! Finally after countless hours I have found the problem. I had not defined a <tei-class> in the .tld file and implemented a TagExtraInfo subclass to make the scripting variables available. Well, I am just starting... It just never occured to me I would even have to do such a thing. I just assumed the container made the scripting variables of parent tags available to child ones... thanks for your help anyhows. john
These are not the droids you are looking for. Perhaps I can interest you in a tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop