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

TagSupport

 
S Subramonyan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What happens if the doAfterBody() of a tag handler class returns EVAL_BODY_BUFFERED ?

When does the error get caught? During compilation or request-time?

I think it will be caught during compilation.

Thanks.
[ September 09, 2004: Message edited by: S Subramonyan ]
 
Bryan Basham
author
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

An error will not be reported by the compiler in this case because the doAfterBody method returns an 'int' and the constant EVAL_BODY_BUFFERED is an 'int'. So from the compiler's perspective, this is fine. In fact, you could have returned 420 from this method and the compiler would not care. The error will be caught by the JSP page that recieves the returned value.

BTW, this type of error could be caught by the compiler if this API had been developed with J2SE 5.0 (Tiger) using the new enum syntax. But Tiger is just now being rolled-out, so, unfortunately, these APIs will continue to use hacked-enums for the indefinite future.

HTH,
Bryan
 
Sekhar Kadiyala
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
doAfterBody(), however can return EVAL_BODY_BUFFERED if the tag handler class implements BodyTag or extends BodyTagSupport (and overrides doAfterBody()).

As brayn said, it is a semantic error, not a syntax error!
 
S Subramonyan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In fact I forgot to add one point to the question. What if the class extends TagSupport? Can the compiler understand EVAL_BODY_BUFFERED? Since there is no such thing in Tag and IterationTag interfaces? Wouldn't it be throwing compilation error?

Please clarify.

Thanks.
[ September 10, 2004: Message edited by: S Subramonyan ]
 
revup triv
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If class extends TagSupport..In that case compiler will throw error I think.
 
S Subramonyan
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya, I thought so too.
 
Sekhar Kadiyala
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have the specs in front of me to confirm this, but if you use it as BodyTag.EVAL_BODY_BUFFERED then there would be no compilation error. But if you just use the variable, i guess it will throw compilation error!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic