Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Don't understand nesting issues

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Marshal
Posts: 67289
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess would be that the problem is with exppressions in attributes, not especially with your iner tag. Try modifying your second example to say:

My guess is that won't work either.
Have you declared your new tag as accepting "rtexpr" in your tld file ?
 
John Summers
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!