Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Parent and Child Tags

Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cannot figure out how the Parent to Child and Child to Parent Tags are working .
There is some code in HFJS pg 573.

Can some one tell me the sequence of how the code is running .
When the setItemValue() and addMenuITem() are running.
Also the sequence of the respective doStartTag() and doEndTAg() runs.

Can't make any sense out of it.!

Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nabila. If jsp page invokes,
first container finds appropriate tld file. After that, Menu tag handler will be invoked and the life cycle of Menu tag handler starts. Loads, setting PageContext object, setting parent (here there is no parent so 'null' will passed), setting attributes(here there are no attributes), and calls the doStartTag(). Here in doStartTag() ArrayList object is created, and return's EVAL_BODY_INCLUDE. Now the container process the body.
Here body of Menu tag includes . First MenuItem tag handler will be invoked and its life cycle starts. Loads first MenuItem class class, instantiate, sets the parent(here parent is Menu tag handler object), sets the attributes(here sets the attribute name "Dogs" by using setItemValue(String name) method of it ), and calls the doStartTag(). Here doStartTag() return's EVAL_BODY_INCLUDE. The body of the MenuItem will be processed(here there is no body). After that it calls the doEndTag() of it. In doEndTag(), gets it's parent tag(Menu tag handler object) and calls the addMenuItem(itemValue) of it by passing the itemValue "Dogs" to it.The addMenuItem(String item) of Menu tag hander adds attribute value "Dogs" to the ArrayList object. Finally it returns EVAL_PAGE, means the rest of page will be evaluated.

Similarly it calls second, third and adds "Cats", "Horses" to ArrayList object.

All this is happened while container processing the body of Menu tag handler. After processing the body, finally container calls the doEndTag() of Menu tag handler class. Here it process
Finally the method returns EVAL_PAGE, and the rest of the page will be evaluated and the response will be sent to the client.
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot Chinmaya , that was a nice and detailed explanation.

Still trying to get a hang out it. Keep forgetting the previous stuff I learned.

Was wondering..How do you write a TLD for nested tags?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic