Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling parent tags.......

 
trivikram Kumar
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pals,

Can someone explain me how the parent tags ara called and in which order the body is evaluated??

The answer would be more helpful if someone could refer to HFS page:539.
In the while loop,the value of nestlevel will increase...and since there are 2 nested levels,the value will be 2 and thats printed.
I do not understand why we get all the three outputs??Whats the order in which the parent tags are called here??

I am trying hard to undertand this..but not clear with this concept...

Thanks in advance,

Javainn(SCJP 1.4)
[ April 21, 2005: Message edited by: S javainn ]
 
trivikram Kumar
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone please help me out on this???
 
chowdary Thammineedi
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was intutive for me when I recalled that the setJspBody() method is called prior to the doStartTag() method in a classic tag. And I left it off there.

Also we need to remember that Custom Tag invocations are resolved at Translation time.

From JSP 2.0 spec page 1-151


The first step is to parse the JSP page. The page that is parsed is as expanded
by the processing of include directives. Information in the TLD is used in this
step, including the identification of custom tags, so there is some processing of the
taglib directives in the JSP page.


So do we have to conclude that the inner most tag's doStartTag() method is called first?

I'm not sure, as I've not tested this yet. I'll be coding this during the weekend.

Meanwhile can somebody please explain this.

Where are Jose Esteban, Praveen Kumar and Bassam Zahid?
 
chowdary Thammineedi
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way I've heard of a Days Inn. (Motel)

Is, Java INN a legitimate Last Name?
 
Kejal Shah
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Even I was stuck with the same reasoning. However, I later realised that the answer is true.

I don't have the book handy, but the JSP goes something like...

<NestedLevel>
<NestedLevel>
<NestedLevel/>
</NestedLevel>
</NestedLevel>

and in the doStartTag,
1. get the parent and increment a var
2. print the var
3. evaluate the body

So, for the NestedLevel (grandparent), we have the var = 0, it prints, calls the body
for NestedLevel (parent), we have var = 1, it prints, calls the body
for NestedLevel (child), we have var = 2, it prints.

So, the result will be
0
1
2

Hope, I was clear
 
trivikram Kumar
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi KejalChowdary and other ranchers,

After breaking my head on this,I could understand how it works..and it matches with what you explained...Thankyou for the effort taken.

Thanks,
Javainn
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic