tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kishi Mikio <mki...@104.net>
Subject Re: pushBody() and popBody() problems in BodyTag
Date Mon, 10 Feb 2003 18:28:59 GMT
From: Kishi Mikio <mkishi@104.net>
Subject: pushBody() and popBody() problems in BodyTag
Date: Thu, 06 Feb 2003 21:21:31 +0900 (JST)

> <fmt:bundle basename="test">
>   <c:out value="test1" />
>   <% if (true) return; %>
> </fmt:bundle>
> 
> In above case, I want to print out "test1", but not print out....
> Is it possible to print out string
> between <fmt:bundle> and "return" ?

In order to solve this problem, I implemented <my:return/> tag.
The following code is doEndTag() in the <my:return/>.

public int doEndTag()
    throws JspException {
    try {
        BodyContent body = (BodyContent) pageContext.getOut();
        try {
            while (true) {
                JspWriter writer = pageContext.popBody();
                body.writeOut(writer);
                body = (BodyContent) writer;
            }
        } catch (EmptyStackException e) {
            // nothing to do
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw new JspException(e.toString());
    }
    return SKIP_PAGE;
}

By using this tag, it became possible to display "test1" string.
But is this the best method ? Is this popBody() usage wrong ?
Is there any other better method ?

Thanks in advance
Mikio Kishi


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message