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

Q. from HFSJ about JspFragment

 
geeta vemula
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thia is Question no 12 in chapter 10(HFSJ second edition)

Q. Which is true about the lifecycle of a Simple tag?

A.

B.

C.The setParent and SetJspContext bmethods are called immediately before the tag attributes are set.

D. The JspFragment of a tag's body is invoked by the container before the tag handler's doTag method is called. This value, a BodyContent object, is passed to the tag handler using the setJspBody method.


Answer is C.

But why D is incorrect, reason given is -the fragment is invoked by the doTag implementation but not before the doTag called.

But in lifecycle of simple tag on page 516 shows that setJspBody(JspFragment) is called before doTag method.

then why is reason is given like that?
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Geeta. The JspFrament is an abstract class, the container provides the concrete class(JspFragmentImpl) by extending the JspFragment abstract class and encapsulates the body of the tag(not invokes) into it.

In the life cycle of simple tag, this object is set via. setJspBody(JspFragment).

The body will be invoked in doTag(), through getJspBody().invoke(java.io.Writer). Where the getJspBody() returns the JspFragmentImpl object, which is having the body of the tag encapsulated into it, and it will be invoked by invoke() method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic