Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@www.apache.org Received: (qmail 51690 invoked from network); 18 Aug 2005 07:55:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Aug 2005 07:55:45 -0000 Received: (qmail 82549 invoked by uid 500); 18 Aug 2005 07:55:39 -0000 Delivered-To: apmail-jakarta-tomcat-dev-archive@jakarta.apache.org Received: (qmail 82506 invoked by uid 500); 18 Aug 2005 07:55:38 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 82492 invoked by uid 99); 18 Aug 2005 07:55:38 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 18 Aug 2005 00:55:38 -0700 Received: (qmail 51609 invoked from network); 18 Aug 2005 07:55:37 -0000 Received: from localhost.hyperreal.org (HELO ?127.0.0.1?) (127.0.0.1) by localhost.hyperreal.org with SMTP; 18 Aug 2005 07:55:37 -0000 Message-ID: <43043EFA.1000706@apache.org> Date: Thu, 18 Aug 2005 09:55:38 +0200 From: Remy Maucherat User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tomcat Developers List Subject: Re: tag plugin References: <20050818031411.72959.qmail@web15906.mail.cnb.yahoo.com> In-Reply-To: <20050818031411.72959.qmail@web15906.mail.cnb.yahoo.com> Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 8bit X-Spam-Rating: localhost.hyperreal.org 1.6.2 0/1000/N X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N wing lee wrote: > I've tried the generateBody method, but it just generate such code > "write.out(body content)", don't return the value of the body content. That's odd: it's supposed to continue evaluation and code generation for the body, not consider nested stuff as static text. There's a good example with the "if" tag plugin (although, as I said, I didn't test it at all, so maybe it's broken). public final class If implements TagPlugin { public void doTag(TagPluginContext ctxt) { String condV = ctxt.getTemporaryVariableName(); ctxt.generateJavaSource("boolean " + condV + "="); ctxt.generateAttribute("test"); ctxt.generateJavaSource(";"); if (ctxt.isAttributeSpecified("var")) { String scope = "PageContext.PAGE_SCOPE"; if (ctxt.isAttributeSpecified("scope")) { String scopeStr = ctxt.getConstantAttribute("scope"); if ("request".equals(scopeStr)) { scope = "PageContext.REQUEST_SCOPE"; } else if ("session".equals(scopeStr)) { scope = "PageContext.SESSION_SCOPE"; } else if ("application".equals(scopeStr)) { scope = "PageContext.APPLICATION_SCOPE"; } } ctxt.generateJavaSource("_jspx_page_context.setAttribute("); ctxt.generateAttribute("var"); ctxt.generateJavaSource(", new Boolean(" + condV + ")," + scope + ");"); } ctxt.generateJavaSource("if (" + condV + "){"); >>>> ctxt.generateBody(); ctxt.generateJavaSource("}"); } } R��my --------------------------------------------------------------------- To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org