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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]