List of usage examples for javax.servlet.jsp.tagext Tag setParent
void setParent(Tag t);
From source file:de.micromata.genome.gwiki.page.gspt.TagSupport.java
/** * @return true if body should be included *//* www. j av a2s. co m*/ public static boolean initTag(Tag tag, List<Object> attributes, ChildPageContext ctx) throws Exception { Tag ptag = ctx.getCurrentTag(); if (log.isDebugEnabled()) log.debug("Init tag: " + tag.getClass().getName()); PageContext pctx = ctx; if (ctx.isUseParentTagContext() == true) pctx = ctx.getParentPageContext(); tag.setPageContext(pctx); tag.setParent(ptag); attributes = evalAttributes(tag, attributes, ctx); setAttributes(tag, attributes, ctx); ctx.setCurrentTag(tag); int r = tag.doStartTag(); ctx.getTagStack().push(new Pair<Tag, Integer>(tag, r)); JspWriter oout = pctx.getOut(); ctx.setInternalGroovyOut(createPrintWriter(oout)); if (r != javax.servlet.jsp.tagext.Tag.SKIP_BODY && r != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE && tag instanceof BodyTag) { BodyTag btag = (BodyTag) tag; JspWriter out = pctx.pushBody(); PrintWriterPatched newPout = createPrintWriter(out, true); ctx.setInternalGroovyOut(newPout); btag.setBodyContent((javax.servlet.jsp.tagext.BodyContent) out); btag.doInitBody(); } boolean ret = r != javax.servlet.jsp.tagext.Tag.SKIP_BODY; if (log.isDebugEnabled()) log.debug("Init tag: " + tag.getClass().getName() + ": " + ret); return ret; }
From source file:de.micromata.genome.gwiki.page.gspt.TagSupport.java
/** * @return if return false page will be skipped *//*from w w w . ja v a 2 s. c o m*/ public static boolean initSimpleTag(Tag tag, List<Object> attributes, ChildPageContext ctx) throws Exception { if (log.isDebugEnabled()) log.debug("Init simple tag: " + tag.getClass().getName()); Tag ptag = ctx.getCurrentTag(); PageContext pctx = ctx;// .getBrickContext().getPageContext(); if (ctx.isUseParentTagContext() == true) pctx = ctx.getParentPageContext(); tag.setPageContext(pctx); tag.setParent(ptag); attributes = evalAttributes(tag, attributes, ctx); setAttributes(tag, attributes, ctx); ctx.setCurrentTag(tag); int r = tag.doStartTag(); // ctx.getTagStack().push(new Pair<Tag, Integer>(tag, r)); r = tag.doEndTag(); // ctx.getTagStack().pop(); ctx.setCurrentTag(ptag); return r != javax.servlet.jsp.tagext.Tag.SKIP_PAGE; }
From source file:com.icesoft.faces.webapp.parser.ComponentRuleSet.java
/** * Because Tag processing classes themselves don't support a tree structure, * a wiring class is used to hold the tree together. This member wires up * the tree appropriately./*from www.j a va 2 s . com*/ * * @param child The child Tag * @param parent The parent Tag * @param childWire The child Wire * @param parentWire The parent Wire */ protected void wireUpTheTag(Tag child, Tag parent, TagWire childWire, TagWire parentWire) { child.setParent(parent); childWire.setTag(child); parentWire.addChild(childWire); }
From source file:com.icesoft.faces.webapp.parser.Parser.java
/** * The main parsing logic. Creates a Digester to parse page into a tag * processing tree, and then executes the JSP lifecycle across that tree. * The end result is a JSF component rooted with a UIViewRoot component. * * @param page The Reader for the page. * @param context//from w ww . j a va 2s . com * @throws java.io.IOException If stream IO fails. * @throws org.xml.sax.SAXException If digester encounters invalid XML. */ public void parse(Reader page, FacesContext context) throws java.io.IOException, org.xml.sax.SAXException { // Need a mock pageContext StubPageContext pageContext = new StubPageContext(context); Set componentIds = new HashSet(); //placeholder tag and wire XhtmlTag rootTag = new XhtmlTag(); rootTag.setTagName("ICEtag"); rootTag.setParent(null); TagWire rootWire = new TagWire(); rootWire.setTag(rootTag); TagWire realViewWire = null; String viewTagClassName = null; synchronized (this) { digester.clear(); digester.push(rootTag); digester.push(rootWire); digester.parse(page); realViewWire = digester.getViewWire(); viewTagClassName = digester.getViewTagClassName(); } try { // #2551 We have captured the real View Tag (from wherever it was in the tree) // now we check to see if it's the first child of this fake root, and // if not, make it so. // We do this by taking all top level siblings of the fake root, and // making them the first children of the real view root, and replacing // the original viewRoot with its children in the hiearchy. // This duplicates what the previous code was doing, except the created // ViewTag has the attributes set Tag viewTag; if (null != realViewWire) { viewTag = realViewWire.getTag(); transmogrifyHierarchy(realViewWire, rootWire); viewTag.setParent(null); } else { //fallback case for pages with no view tag if (null == viewTagClassName) throw new IllegalStateException( "ICEfaces parser unable to determine JSF implementation ViewTag class."); viewTag = (Tag) Class.forName(viewTagClassName).newInstance(); rootWire.setTag(viewTag); realViewWire = rootWire; viewTag.setParent(null); } executeJspLifecycle(realViewWire, pageContext, context, componentIds); pageContext.removeAttribute("javax.faces.webapp.COMPONENT_TAG_STACK", PageContext.REQUEST_SCOPE); pageContext.removeAttribute("javax.faces.webapp.GLOBAL_ID_VIEW", PageContext.REQUEST_SCOPE); } catch (Exception e) { log.error("Failed to execute JSP lifecycle.", e); if (log.isDebugEnabled()) { log.debug("Dumping Tag Hierarchy"); if (realViewWire != null) { displayHierarchy(realViewWire); } else { displayHierarchy(rootWire); } } throw new FacesException("Failed to execute JSP lifecycle.", e); } }
From source file:org.apache.cactus.extension.jsp.JspTagLifecycle.java
/** * Adds a nested tag. The tag will be invoked when the body content of the * enclosing tag is evaluated.//w w w . ja v a 2s .c o m * * @return The lifecycle wrapper for the nested tag, can be used to add * expectations for the nested tag * @param theNestedTag The tag to be nested */ public JspTagLifecycle addNestedTag(Tag theNestedTag) { if (theNestedTag == null) { throw new NullPointerException(); } JspTagLifecycle lifecycle = new JspTagLifecycle(this.pageContext, theNestedTag); theNestedTag.setParent(this.tag); addInterceptor(new NestedTagInterceptor(lifecycle)); return lifecycle; }
From source file:org.seasar.mayaa.impl.engine.processor.JspProcessor.java
public ProcessStatus doStartProcess(Page topLevelPage) { if (_tagClass == null) { throw new IllegalStateException(); }/*w ww . j a v a2 s.com*/ 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); } }