public final class When implements TagPlugin {
public void doTag(TagPluginContext ctxt) {
// Get the parent context to determine if this is the first <c:when>
TagPluginContext parentContext = ctxt.getParentContext();
if (parentContext == null) {
ctxt.dontUseTagPlugin();
return;
}
if ("true".equals(parentContext.getPluginAttribute("hasBeenHere"))) {
ctxt.generateJavaSource("} else if(");
// See comment below for the reason we generate the extra "}" here.
} else {
ctxt.generateJavaSource("if(");
parentContext.setPluginAttribute("hasBeenHere", "true");
}
ctxt.generateAttribute("test");
ctxt.generateJavaSource("){");
ctxt.generateBody();