Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issue with BodyTagSupport

 
Adri Smith
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,

I am actually trying to make a taglib which is responsible to display few lines which are constants (depends on no attributes or content). Actually the last line is a simple html line ("<script>...</script>"), the rest is a call to another tag (this call is always the same call ("<mytag>...</mytag>").

How to make it work ? Here is a part of what I have done:

public class IncludeCalendar extends BodyTagSupport {

private BodyContent bodyContent;

public void setBodyContent(BodyContent bodyContent) {
this.bodyContent = bodyContent;
JspWriter out = bodyContent.getEnclosingWriter();
try {
out.println("<mytag>...</mytag>");
} catch (IOException ex) {
ex.printStackTrace();
}
}

public int doStartTag() throws JspException {
return this.EVAL_BODY_BUFFERED;
}

public int doEndTag() throws JspException {
try {
JspWriter out = pageContext.getOut();
out.print("<script language=\"Javascript\" type=\"text/javascript\"> .... </script> ");
} catch (Exception ex) {
ex.printStackTrace();
}
return EVAL_PAGE;
}
}

Apparently the body is not processed... it displays only the tag html <script>

Thanks in advance for your help,
Adri
 
Deepa Korecherla
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
B'coz the doAfterBody() method returns skip-body by default, therefore,it has not processed the body. implement the doAfterbody and return eval-body-again/buffered.
Try it & don't forget to post the result whatever u got.
 
Adri Smith
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First I would like to thank you a lot for spending a little time to help me.

Actually I have tried to in fact return EVAL_BODY_BUFFERED it displays in my HMTL generated page:
<mytag>...</mytag>
<script>...</script>

This is better but the tag <mytag> is not translated... Do you have an idea how to make it translated ?

Thanks again for your precious help,
Adri
 
Deepa Korecherla
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Explain ur problems clearly...its hard to understnd..make it more clear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic