Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in SimpleTag and ClassicTag Nesting

 
raja ram
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi,

Any updates on this.

Thanks
 
Matteo Palmieri
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • 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 ]
 
Charles Lyons
Author
Ranch Hand
Posts: 836
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic