public CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, TagInfo tagInfo, Class<?> tagHandlerClass) { super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); this.uri = uri; this.prefix = prefix; this.tagInfo = tagInfo; this.tagHandlerClass = tagHandlerClass; this.customNestingLevel = makeCustomNestingLevel(); this.childInfo = new ChildInfo(); this.implementsIterationTag = IterationTag.class.isAssignableFrom(tagHandlerClass); this.implementsBodyTag = BodyTag.class.isAssignableFrom(tagHandlerClass); this.implementsTryCatchFinally = TryCatchFinally.class.isAssignableFrom(tagHandlerClass); this.implementsSimpleTag = SimpleTag.class.isAssignableFrom(tagHandlerClass); this.implementsDynamicAttributes = DynamicAttributes.class.isAssignableFrom(tagHandlerClass); this.implementsJspIdConsumer = JspIdConsumer.class.isAssignableFrom(tagHandlerClass); }
@Override public String execute() throws Exception { if (tag != null) { try { getValueStack().push(tag); for (Entry<String, Object> dynamicAttribute : getDynamicAttributes().entrySet()) { getValueStack().setValue(dynamicAttribute.getKey(), dynamicAttribute.getValue()); } } finally { getValueStack().pop(); } } if (tagBody == null) { tagBody = getJspBody(); } if (tag instanceof SimpleTag) { processTag((SimpleTag) tag); } else if (tag instanceof Tag) { processTag((Tag) tag); } return null; }
public CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, TagInfo tagInfo, Class<?> tagHandlerClass) { super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); this.uri = uri; this.prefix = prefix; this.tagInfo = tagInfo; this.tagHandlerClass = tagHandlerClass; this.customNestingLevel = makeCustomNestingLevel(); this.childInfo = new ChildInfo(); this.implementsIterationTag = IterationTag.class .isAssignableFrom(tagHandlerClass); this.implementsBodyTag = BodyTag.class .isAssignableFrom(tagHandlerClass); this.implementsTryCatchFinally = TryCatchFinally.class .isAssignableFrom(tagHandlerClass); this.implementsSimpleTag = SimpleTag.class .isAssignableFrom(tagHandlerClass); this.implementsDynamicAttributes = DynamicAttributes.class .isAssignableFrom(tagHandlerClass); this.implementsJspIdConsumer = JspIdConsumer.class .isAssignableFrom(tagHandlerClass); }
public CustomTag(String qName, String prefix, String localName, String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, TagInfo tagInfo, Class tagHandlerClass) { super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); this.uri = uri; this.prefix = prefix; this.tagInfo = tagInfo; this.tagHandlerClass = tagHandlerClass; this.customNestingLevel = makeCustomNestingLevel(); this.childInfo = new ChildInfo(); this.implementsIterationTag = IterationTag.class .isAssignableFrom(tagHandlerClass); this.implementsBodyTag = BodyTag.class .isAssignableFrom(tagHandlerClass); this.implementsTryCatchFinally = TryCatchFinally.class .isAssignableFrom(tagHandlerClass); this.implementsSimpleTag = SimpleTag.class .isAssignableFrom(tagHandlerClass); this.implementsDynamicAttributes = DynamicAttributes.class .isAssignableFrom(tagHandlerClass); this.implementsJspIdConsumer = JspIdConsumer.class .isAssignableFrom(tagHandlerClass); }
public CustomTag(String jspVersion, String qName, String prefix, String localName, String uri, Attributes attrs, Attributes nonTaglibXmlnsAttrs, Attributes taglibAttrs, Mark start, Node parent, TagInfo tagInfo, Class tagHandlerClass) { super(qName, localName, attrs, nonTaglibXmlnsAttrs, taglibAttrs, start, parent); this.jspVersion = Double.valueOf(jspVersion).doubleValue(); this.uri = uri; this.prefix = prefix; this.tagInfo = tagInfo; this.tagHandlerClass = tagHandlerClass; this.customNestingLevel = makeCustomNestingLevel(); this.childInfo = new ChildInfo(); this.implementsIterationTag = IterationTag.class.isAssignableFrom(tagHandlerClass); this.implementsBodyTag = BodyTag.class.isAssignableFrom(tagHandlerClass); this.implementsTryCatchFinally = TryCatchFinally.class.isAssignableFrom(tagHandlerClass); this.implementsSimpleTag = SimpleTag.class.isAssignableFrom(tagHandlerClass); this.implementsDynamicAttributes = DynamicAttributes.class.isAssignableFrom(tagHandlerClass); }
/** * Tests that event tag's parents are scanned deeply to find a BuilderTagBase parent. */ public void testBuildGrid_EventsWithIndirectBuilderParentTag() throws Exception { final EventTag rowStartTag = initEvent("rowStart", '^'); final EventTag rowEndTag = initEvent("rowEnd", '$'); final SimpleTag cellTagParent = new SimpleTagSupport() { @Override public void doTag() throws IOException, JspException { getJspBody().invoke(getJspContext().getOut()); } }; cellTagParent.setJspContext(ctx); cellTagParent.setParent(gridTag); final EventTag cellTag = initEvent(cellTagParent, "cell", '-'); cellTagParent.setJspBody(new CallTagsJspFragment(cellTag)); final CallTagsJspFragment body = new CallTagsJspFragment("foo", rowStartTag, rowEndTag, cellTagParent); gridTag.setJspBody(body); gridTag.rowCount = 3; gridTag.columnCount = 2; gridTag.doTag(); assertTrue(gridTag.buildInvoked); assertTrue(body.invoked); assertEquals("^--$^--$^--$", out.getOutput()); }
@Override public void invoke(final Writer out) throws JspException, IOException { Assert.assertFalse(invoked); invoked = true; out.write(textToWrite); for (final SimpleTag tag : tags) { tag.doTag(); } }
public TagPool(Class clazz) { if (isSupportClass(clazz) == false) { throw new IllegalArgumentException(); } _clazz = clazz; _isSimpleTag = SimpleTag.class.isAssignableFrom(_clazz); }
public Tag borrowTag() { if (_isSimpleTag) { // SimpleTagはプールしない return new SimpleTagWrapper((SimpleTag) ObjectUtil.newInstance(_clazz)); } return (Tag) borrowObject(); }
public Tag getParent() { if (!_parentDetermined) { JspTag simpleTagParent = _simpleTag.getParent(); if (simpleTagParent != null) { if (simpleTagParent instanceof Tag) { _parent = (Tag) simpleTagParent; } else { _parent = new SimpleTagWrapper((SimpleTag) simpleTagParent); } } _parentDetermined = true; } return _parent; }
void processTag(SimpleTag tag) throws JspException, IOException { tag.setJspContext(getJspContext()); tag.doTag(); }
public CallTagsJspFragment(final SimpleTag... tags) { this("", tags); }
public CallTagsJspFragment(final String textToWrite, final SimpleTag... tags) { Assert.assertNotNull(tags); this.tags = tags; this.textToWrite = textToWrite; }
public static boolean isSupportClass(Class test) { return test != null && (Tag.class.isAssignableFrom(test) || SimpleTag.class.isAssignableFrom(test)); }
public ProcessStatus doStartProcess(Page topLevelPage) { if (_tagClass == null) { throw new IllegalStateException(); } 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); } }
protected Object createObject() { if (Tag.class.isAssignableFrom(_clazz)) { return ObjectUtil.newInstance(_clazz); } return new SimpleTagWrapper((SimpleTag) ObjectUtil.newInstance(_clazz)); }
public SimpleTagWrapper(SimpleTag simpleTag) { if (simpleTag == null) { throw new IllegalArgumentException("simpleTag is null"); } this._simpleTag = simpleTag; }
public SimpleTag getSimpleTag() { return _simpleTag; }