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

Doubt regarding Custom tags

 
Raj Menon
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

In the HFSJ mock exam 12th question

In the tld - "<body-content>empty<body-content>"
is defined.

But in the Tag handler class - It is returning
EVAL_BODY_INCLUDE in the doStartTag() method.

Will that not cause any compile time or runtime error?

In the JSP any way there is no body specified
for the tags that use this Taghandler class.

How it will evaluate body if there is no body in the JSP?


If we assume that it won't cause any error then
can we interpret it as - we can return anything
from doStartTag() method irrespective of the
declaration in the tld.

Is that correct?

Thanks in advance..
[ August 08, 2007: Message edited by: Rajesh Kodali ]
 
Srinivasan thoyyeti
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should result in translation error.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajesh:

No error at all.
There is only error when in the tld you have
<body-content>empty</body-content>, and you try to make a body like
<myTag:emptyTest></myTag:emptyTest>

As it must be </myTag:emptyTest>.

Note: As I think, when tld says <body-content> empty, what doStart()
returns is ignored.

Any idea?

Thanks,
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My doubt:

What if I return SKIP_PAGE from the doStart() method while extending
TagSupport class.

I don't see any impact of this because still doAfterBody() is called.

Is it like, only SKIP_BODY and EVAL_BODY_INCLUDE are the two recognizable
values from the doStart().
Shouldn't it give an error while returning any other values besides these
two?


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