List of usage examples for javax.servlet.jsp.tagext VariableInfo NESTED
int NESTED
To view the source code for javax.servlet.jsp.tagext VariableInfo NESTED.
Click Source Link
From source file:ch.entwine.weblounge.taglib.content.ContentIteratorTagExtraInfo.java
/** * Returns the information on the exported tag variables. * /* w w w . j a va2s .co m*/ * @see javax.servlet.jsp.tagext.TagExtraInfo#getVariableInfo(javax.servlet.jsp.tagext.TagData) */ public VariableInfo[] getVariableInfo(TagData tagData) { List<VariableInfo> varinfo = new ArrayList<VariableInfo>(); // Add the default variables varinfo.add(new VariableInfo(ContentIteratorTagVariables.INDEX, Integer.class.getName(), true, VariableInfo.NESTED)); varinfo.add(new VariableInfo(ContentIteratorTagVariables.ITERATIONS, Integer.class.getName(), true, VariableInfo.NESTED)); // Define elements String elements = tagData.getAttributeString("elements"); if (StringUtils.isNotBlank(elements)) { try { TagVariableDefinitions elementVariables = TagVariableDefinitionParser.parse(elements); for (TagVariableDefinition def : elementVariables) { String name = def.getAlias() != null ? def.getAlias() : def.getName(); varinfo.add(new VariableInfo(name, String.class.getName(), true, VariableInfo.NESTED)); } } catch (ParseException e) { logger.info("Error parsing element definition '{}': {}", elements, e.getMessage()); } } // Define properties String properties = tagData.getAttributeString("properties"); if (StringUtils.isNotBlank(properties)) { try { TagVariableDefinitions propertyVariables = TagVariableDefinitionParser.parse(properties); for (TagVariableDefinition def : propertyVariables) { String name = def.getAlias() != null ? def.getAlias() : def.getName(); varinfo.add(new VariableInfo(name, String.class.getName(), true, VariableInfo.NESTED)); } } catch (ParseException e) { logger.info("Error parsing property definition '{}': {}", properties, e.getMessage()); } } return varinfo.toArray(new VariableInfo[varinfo.size()]); }
From source file:org.apache.jasper.compiler.TagLibraryInfoImpl.java
TagVariableInfo createVariable(TreeNode elem) {
String nameGiven = null;// w w w. j a v a 2 s .co m
String nameFromAttribute = null;
String className = "java.lang.String";
boolean declare = true;
int scope = VariableInfo.NESTED;
Iterator list = elem.findChildren();
while (list.hasNext()) {
TreeNode element = (TreeNode) list.next();
String tname = element.getName();
if ("name-given".equals(tname))
nameGiven = element.getBody();
else if ("name-from-attribute".equals(tname))
nameFromAttribute = element.getBody();
else if ("variable-class".equals(tname))
className = element.getBody();
else if ("declare".equals(tname)) {
String s = element.getBody();
if (s != null)
declare = JspUtil.booleanValue(s);
} else if ("scope".equals(tname)) {
String s = element.getBody();
if (s != null) {
if ("NESTED".equals(s)) {
scope = VariableInfo.NESTED;
} else if ("AT_BEGIN".equals(s)) {
scope = VariableInfo.AT_BEGIN;
} else if ("AT_END".equals(s)) {
scope = VariableInfo.AT_END;
}
}
} else if ("description".equals(tname) || // Ignored elements
false) {
} else {
if (log.isWarnEnabled()) {
log.warn(Localizer.getMessage("jsp.warning.unknown.element.in.variable", tname));
}
}
}
return new TagVariableInfo(nameGiven, nameFromAttribute, className, declare, scope);
}
From source file:org.apache.jasper.runtime.JspContextWrapper.java
/** * Synchronize variables before fragment invokation */ public void syncBeforeInvoke() { copyTagToPageScope(VariableInfo.NESTED); copyTagToPageScope(VariableInfo.AT_BEGIN); }
From source file:org.apache.jasper.runtime.JspContextWrapper.java
/** * Copies the variables of the given scope from the virtual page scope of * this JSP context wrapper to the page scope of the invoking JSP context. * * @param scope variable scope (one of NESTED, AT_BEGIN, or AT_END) *//* w ww .j av a 2s. c om*/ private void copyTagToPageScope(int scope) { Iterator iter = null; switch (scope) { case VariableInfo.NESTED: if (nestedVars != null) { iter = nestedVars.iterator(); } break; case VariableInfo.AT_BEGIN: if (atBeginVars != null) { iter = atBeginVars.iterator(); } break; case VariableInfo.AT_END: if (atEndVars != null) { iter = atEndVars.iterator(); } break; } while ((iter != null) && iter.hasNext()) { String varName = (String) iter.next(); Object obj = getAttribute(varName); varName = findAlias(varName); if (obj != null) { invokingJspCtxt.setAttribute(varName, obj); } else { invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE); } } }
From source file:org.seasar.mayaa.impl.engine.processor.JspProcessor.java
protected void operateNestedVariables(NestedVariableOperator operator) { if (Boolean.FALSE.equals(_nestedVariableExists) == false) { TLDScriptingVariableInfo variableInfo = getTLDScriptingVariableInfo(); if (variableInfo != null) { AttributeScope pageScope = CycleUtil.getServiceCycle().getPageScope(); boolean firstHit = true; for (Iterator it = variableInfo.variableInfos(); it.hasNext();) { VariableInfo info = (VariableInfo) it.next(); if (info.getScope() == VariableInfo.NESTED) { _nestedVariableExists = Boolean.TRUE; operator.operate(pageScope, info, firstHit); firstHit = false;/* ww w.j av a 2s. com*/ } } } if (_nestedVariableExists == null) { _nestedVariableExists = Boolean.FALSE; } } }
From source file:org.tinygroup.jspengine.compiler.TagLibraryInfoImpl.java
private TagVariableInfo createVariable(TreeNode elem) throws JasperException { String nameGiven = null;// w ww. ja va 2 s . co m String nameFromAttribute = null; String className = "java.lang.String"; boolean declare = true; int scope = VariableInfo.NESTED; Iterator list = elem.findChildren(); while (list.hasNext()) { TreeNode element = (TreeNode) list.next(); String tname = element.getName(); if ("name-given".equals(tname)) nameGiven = element.getBody(); else if ("name-from-attribute".equals(tname)) nameFromAttribute = element.getBody(); else if ("variable-class".equals(tname)) className = element.getBody(); else if ("declare".equals(tname)) { String s = element.getBody(); if (s != null) declare = JspUtil.booleanValue(s); } else if ("scope".equals(tname)) { String s = element.getBody(); if (s != null) { if ("NESTED".equals(s)) { scope = VariableInfo.NESTED; } else if ("AT_BEGIN".equals(s)) { scope = VariableInfo.AT_BEGIN; } else if ("AT_END".equals(s)) { scope = VariableInfo.AT_END; } } } else if ("description".equals(tname) || // Ignored elements false) { } else { err.jspError("jsp.error.unknown.element.in.variable", tname); } } return new TagVariableInfo(nameGiven, nameFromAttribute, className, declare, scope); }