Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tag Library Question  RSS feed

 
Billy Hause
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm new to tag libraries and I'm having the following problem.
In my tag class I override doAfterBody()
Inside doAfterBody() I call getBodyContent() but it returns null.
Does anyone know why it would be returning null?
In my jsp, there is text between the start and end tags.
My tag class extends BodyTagSupport.
In my '.tld' my tag has
<bodycontent>JSP</bodycontent>
Thanks for any suggestions.
-Bill
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Billy"
Thanks for participating here at the Ranch. However, the name you are using does not comply with the naming convention described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name (not fictitious monikers). Please log in with a new name which meets the requirements.
Thanks.
Sean
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you returning EVAL_BODY_BUFFERED from the doStartTag() method?
Simon
 
Billy Hause
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Changed the return value in my doStartTag from
return EVAL_BODY_INCLUDE to
reutrn EVAL_BODY_BUFFERED.
This compiles fine but when I run I get this exception:
javax.servlet.jsp.JspTagException: Since tag handler class hause.test.MagicWords does not implement BodyTag, it can't return BodyTag.EVAL_BODY_TAG
My class does extend BodyTagSupport so it should implement BodyTag.
public class MagicWords extends BodyTagSupport {
Anyone know what's going on here?
Thanks,
Billy
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of things to check ... perhaps the tag handler class is still cached by the container, or perhaps you have two classes with the same name on the container's classpath.
Wrox have kindly provided a couple of chapters from Professional JSP Tag Libraries to download, one of which talks extensively about body tags.
Hope that helps
Simon
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!