tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Micael Padraig Og mac Grene <caraun...@harbornet.com>
Subject RE: Processing BodyContent in doAfterTag() has no effect
Date Fri, 08 Mar 2002 23:18:11 GMT
Why don't you use a replace function instead of all this rigamorole?

At 10:57 PM 3/8/02 +0000, you wrote:
>Thanks for your help. But I don't think that is
>causing the problem:
>   (a) for one thing, the other text written to
>      body content show up in the output. Only the
>      stuff inserted into the enclosing writer in
>      doAfterBody() is mysteriously missing.
>
>   (b) I am writing to the enclosing JspWriter -
>       not to the body content.
>
>Consider the following:
>
>       <body>
>           <kobe:Filter>
>             I am a Laker Fan. I am Kobe.
>           </kobe:Filter>
>       <body>
>
>What appears on output is:
>      I AM A LAKER FAN I AM KOBE
>
>The periods are missing. What (I think) my doAfterBody()
>is doing is to replace "." tokens with ".<br>" tokens.
>Can you tell me where the <br> tokens that I inserted
>vanished?
>
>      /K
>
>On Fri, 8 Mar 2002 01:52:33 -0500  Ryan Daigle <RDaigle@healthdec.com> wrote:
> >I believe you have to flush the writer out to the body content of the tag at
> >the end tag event:
> >
> >doEndTag() throws JspException {
> >       bodyContent.writeOut(YourWriter);
> >}
> >
> >That work?
> >
> >-----Original Message-----
> >From: K Br [mailto:kobe@ny.com]
> >Sent: Thursday, March 07, 2002 6:29 PM
> >To: tomcat-user@jakarta.apache.org
> >Subject: Processing BodyContent in doAfterTag() has no effect
> >
> >
> >This is no JSP forum and I understand that.
> >I would appreciate any pointers on this.
> >
> >Using Tomcat4.0.2 I have written a custom tag with body.
> >The intention is to process the body and
> >replace any periods with line breaks (in HTML)
> >before writing the BodyContent to the
> >enclosing JspWriter.
> >
> >It seems that replacing "." with ".<br>" does not
> >take any effect. The output HTML does not contain
> >the <br> tags (when viewed from the browser).
> >
> >From the doAfterBody() I call the filter
> >to replace the periods with <br> as follows.
> >
> >Pl let me know if my understanding of the
> >TAG lifecycle is wrong:
> >
> >public int doAfterBody() throws JspException {
> >try {
> >String txt = getBodyContent().getString();
> >replaceDots(txt.toLowerCase()
> >getPreviousOut()
> >);
> >}
> >catch (java.io.IOException ioxc) {
> >throw new JspException(ioxc.toString());
> >}
> >
> >return SKIP_BODY;
> >}
> >
> >private void replaceDots(final String x, JspWriter w)
> >throws java.io.IOException
> >{
> >if (x == null) return ;
> >StringTokenizer st = new StringTokenizer(x, ".");
> >while (st.hasMoreTokens()) {
> >String f = (String)st.nextToken();
> >w.println( f.equals(".") ? ".<br>":f);
> >}
> >}
> >
> >
> >
> >--
> >To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> >For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
> >Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
> >
> >--
> >To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
> >For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
> >Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>
> >
> >
>
>
>
>--
>To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
>For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
>Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>



--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message