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.!
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.
. 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.
Finally the method returns EVAL_PAGE, and the rest of the page will be evaluated and the response will be sent to the client.
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?