List of usage examples for javax.servlet.jsp.tagext SimpleTag setJspBody
public void setJspBody(JspFragment jspBody);
From source file:de.micromata.genome.gwiki.page.gspt.TagSupport.java
public static void initSimpleSimpleTag(SimpleTag tag, List<Object> attributes, final ChildPageContext ctx, final Closure body) throws Exception { if (log.isDebugEnabled()) log.debug("Init simple tag: " + tag.getClass().getName()); Tag ptag = ctx.getCurrentTag();// ww w. j ava 2 s . c om final JspContext pctx;// .getBrickContext().getPageContext(); if (ctx.isUseParentTagContext() == true) { pctx = ctx.getParentPageContext(); } else { pctx = ctx; } tag.setJspContext(pctx); tag.setParent(ptag); attributes = evalAttributes(tag, attributes, ctx); setAttributes(tag, attributes, ctx); final TagAdapter tagAdapter = new TagAdapter(tag); ctx.setCurrentTag(tagAdapter); tag.setJspBody(new JspFragment() { @Override public JspContext getJspContext() { return pctx; } @Override public void invoke(Writer out) throws JspException, IOException { ctx.getTagStack().push(new Pair<Tag, Integer>(tagAdapter, -1)); try { JspWriter oldOut = null; try { if (pctx instanceof ChildPageContext) { oldOut = pctx.getOut(); if (out != oldOut) { ((ChildPageContext) pctx).setInternalGroovyOut(createPrintWriter(out)); } else { oldOut = null; } } body.call(); } finally { if (oldOut != null) { pctx.getOut().flush(); ((ChildPageContext) pctx).setInternalGroovyOut(createPrintWriter(oldOut)); } } } finally { ctx.getTagStack().pop(); } } }); tag.doTag(); ctx.setCurrentTag(ptag); }
From source file:org.seasar.mayaa.impl.engine.processor.JspProcessor.java
public ProcessStatus doStartProcess(Page topLevelPage) { if (_tagClass == null) { throw new IllegalStateException(); }/*from ww w . j av a 2 s .c o m*/ topLevelPage.registBeginRenderNotifier(this); clearLoadedTag(); Tag customTag = getLoadedTag(); // javax.servlet.jsp.tagext.SimpleTag Object targetTag = customTag; if (customTag instanceof SimpleTagWrapper) { SimpleTagWrapper simpleTagWrapper = (SimpleTagWrapper) customTag; SimpleTag simpleTag = simpleTagWrapper.getSimpleTag(); int childProcessorSize = getChildProcessorSize(); if (childProcessorSize > 0) { simpleTag.setJspBody(new ProcessorFragment(simpleTagWrapper, this, topLevelPage)); } targetTag = simpleTag; } for (Iterator it = iterateProperties(); it.hasNext();) { ProcessorProperty property = (ProcessorProperty) it.next(); ObjectUtil.setProperty(targetTag, property.getName().getQName().getLocalName(), property.getValue().execute(null)); } // javax.servlet.jsp.tagext.DynamicAttributes if (TLDProcessorDefinition.class.isAssignableFrom(getProcessorDefinition().getClass())) { TLDProcessorDefinition tldDef = (TLDProcessorDefinition) getProcessorDefinition(); if (tldDef.isDynamicAttribute()) { setupDynamicAttributes(customTag); } } ProcessorTreeWalker processor = this; while ((processor = processor.getParentProcessor()) != null) { if (processor instanceof JspProcessor) { JspProcessor jspProcessor = (JspProcessor) processor; Tag parentTag = jspProcessor.getLoadedTag(); if (parentTag == null) { throw new IllegalStateException("the parent processor has no custom tag."); } customTag.setParent(parentTag); break; } } try { pushNestedVariables(); return getProcessStatus(customTag.doStartTag(), true); } catch (JspException e) { throw createJspRuntimeException(getOriginalNode(), getInjectedNode(), e); } }