• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt in SimpleTag and ClassicTag Nesting

 
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have following code in tag handler.


and in Jsp i have
<test:child>
<test:child>
<test:child />
</test:child>
</test:child>

I am able to traverse over all the nested tags and getting correct out put like
getParent() from Child
getParent() from Child
getParent() ----> i is 1
getParent() from Child
getParent() ----> i is 1
getParent() ----> i is 2

but in the below code using Simpletags

and in jsp i have
<test:testing user="s_1">
<test:testing user="s_2" />
</test:testing>
but I am getting out put as
hi this is from the CUSTOM testag s_1
why is that it is not moving one more level inside and getting the parent value and executing while loop
what is actually the problem here.

even in HFSJ we have tag nesting example with Classic tag but not with SimpleTag can any one give me correct
example for SimpleTag.

Thanks
 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Any updates on this.

Thanks
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm studying right now for the exam too, so my explanation may not be technically accurate, but I think that the problem here is that the action's body is not evaluated. In a SimpleTag a body is only evaluated when the you call the method. In your example the body actually appears to be another instance of the same action, so the lifecycle of the tag handler for the nested instance of the action never starts. The resulting effect is that the method setParent on the nested tag is never called.
I hope this helps!
[ September 10, 2008: Message edited by: Matteo Palmieri ]
 
Author
Posts: 836
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The way Matteo describes it is exactly right. If you want cooperating SimpleTags, you need to call the JspFragment's invoke method on each one first in order that the children are instantiated by the container and their lifecycle starts. Then you can use secondary methods to actually evaluate/print the body of the tag. If you want to create cooperating actions, it's usually easier to use classic tags because of all the extra lifecycle methods you get given, so you don't need to simulate them yourself.
 
reply
    Bookmark Topic Watch Topic
  • New Topic