| Author |
Issue with BodyTagSupport
|
Adri Smith
Ranch Hand
Joined: Jun 07, 2004
Posts: 76
|
|
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
Joined: Jul 14, 2004
Posts: 197
|
|
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.
|
DKR<br />SCJP1.2,SCWCD1.4,SCBCD1.3,SCJA
|
 |
Adri Smith
Ranch Hand
Joined: Jun 07, 2004
Posts: 76
|
|
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
Joined: Jul 14, 2004
Posts: 197
|
|
|
Explain ur problems clearly...its hard to understnd..make it more clear
|
 |
 |
|
|
subject: Issue with BodyTagSupport
|
|
|