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.
SCJP5.0, SCWCD5.0, OCEJPAD6, OCPJWSD6
posted 10 years ago
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?
The future belongs to those who believe in the beauty of their dreams.Dream BIG!