public RenderOnDemandClosure(JellyContext context, String attributesToCapture) { List<Script> bodyStack = new ArrayList<Script>(); for (JellyContext c = context; c!=null; c=c.getParent()) { Script script = (Script) c.getVariables().get("org.apache.commons.jelly.body"); if(script!=null) bodyStack.add(script); } this.bodyStack = bodyStack.toArray(new Script[bodyStack.size()]); assert !bodyStack.isEmpty(); // there must be at least one, which is the direct child of <l:renderOnDemand> Map<String,Object> variables = new HashMap<String, Object>(); for (String v : Util.fixNull(attributesToCapture).split(",")) variables.put(v.intern(),context.getVariable(v)); // capture the current base of context for descriptors currentDescriptorByNameUrl = Descriptor.getCurrentDescriptorByNameUrl(); this.variables = PackedMap.of(variables); Set<String> _adjuncts = AdjunctsInPage.get().getIncluded(); this.adjuncts = new String[_adjuncts.size()]; int i = 0; for (String adjunct : _adjuncts) { this.adjuncts[i++] = adjunct.intern(); } }
/** * @return the scope of the given name, such as the 'parent' scope. * If Jelly is used in a Servlet situation then 'request', 'session' and 'application' are other names * for scopes */ public JellyContext getScope(String name) { if ( "parent".equals( name ) ) { return getParent(); } return null; }
/** * @return the scope of the given name, such as the 'parent' scope. * If Jelly is used in a Servlet situation then 'request', 'session' and 'application' are other names * for scopes */ public JellyContext getScope(String name) { if ( "parent".equals( name ) ) { return getParent(); } return null; }
/** * @return the scope of the given name, such as the 'parent' scope. * If Jelly is used in a Servlet situation then 'request', 'session' and 'application' are other names * for scopes */ public JellyContext getScope(String name) { if ( "parent".equals( name ) ) { return getParent(); } return null; }
/** * @return the scope of the given name, such as the 'parent' scope. * If Jelly is used in a Servlet situation then 'request', 'session' and 'application' are other names * for scopes */ public JellyContext getScope(String name) { if ( "parent".equals( name ) ) { return getParent(); } return null; }
/** Sets the value of the named variable */ public void setVariable(String name, Object value) { if ( isExport() ) { getParent().setVariable( name, value ); return; } if (value == null) { variables.remove(name); } else { variables.put(name, value); } }
/** Sets the value of the named variable */ public void setVariable(String name, Object value) { if ( isExport() ) { getParent().setVariable( name, value ); return; } variables.put(name, value); }
/** Sets the value of the named variable */ public void setVariable(String name, Object value) { if ( isExport() ) { getParent().setVariable( name, value ); return; } variables.put(name, value); }
/** Sets the value of the named variable */ public void setVariable(String name, Object value) { if ( isExport() ) { getParent().setVariable( name, value ); return; } variables.put(name, value); }
/** * Gets the value of the variable, or if it's not defined, return the given default value object. */ public Object getVariableWithDefaultValue(String name, Object defaultValue) { Object value = variables.get(name); boolean definedHere = value != null || variables.containsKey(name); if (definedHere) return value; value = defaultValue; if (isInherit()) { JellyContext parentContext = getParent(); if (parentContext != null) { value = parentContext.getVariableWithDefaultValue(name, defaultValue); } } return value; }
public void doTag(XMLOutput output) throws JellyTagException { getBody().run(context.getParent(), output); } }
public void doTag(XMLOutput output) throws JellyTagException { getBody().run(context.getParent(), output); } }
/** @return the value of the given variable name */ public Object getVariable(String name) { Object value = variables.get(name); boolean definedHere = value != null || variables.containsKey(name); if (definedHere) return value; if ( value == null && isInherit() ) { JellyContext parentContext = getParent(); if (parentContext != null) { value = parentContext.getVariable( name ); } } // ### this is a hack - remove this when we have support for pluggable Scopes if ( value == null ) { value = getSystemProperty(name); } return value; }
public RenderOnDemandClosure(JellyContext context, String attributesToCapture) { List<Script> bodyStack = new ArrayList<Script>(); for (JellyContext c = context; c!=null; c=c.getParent()) { Script script = (Script) c.getVariables().get("org.apache.commons.jelly.body"); if(script!=null) bodyStack.add(script); } this.bodyStack = bodyStack.toArray(new Script[bodyStack.size()]); assert !bodyStack.isEmpty(); // there must be at least one, which is the direct child of <l:renderOnDemand> Map<String,Object> variables = new HashMap<String, Object>(); for (String v : Util.fixNull(attributesToCapture).split(",")) variables.put(v.intern(),context.getVariable(v)); // capture the current base of context for descriptors currentDescriptorByNameUrl = Descriptor.getCurrentDescriptorByNameUrl(); this.variables = PackedMap.of(variables); Set<String> _adjuncts = AdjunctsInPage.get().getIncluded(); this.adjuncts = new String[_adjuncts.size()]; int i = 0; for (String adjunct : _adjuncts) { this.adjuncts[i++] = adjunct.intern(); } }
/** @return the value of the given variable name */ public Object getVariable(String name) { Object value = variables.get(name); boolean definedHere = value != null || variables.containsKey(name); if (definedHere) return value; if ( value == null && isInherit() ) { JellyContext parentContext = getParent(); if (parentContext != null) { value = parentContext.getVariable( name ); } } // ### this is a hack - remove this when we have support for pluggable Scopes if ( value == null ) { value = getSystemProperty(name); } return value; }
/** @return the value of the given variable name */ public Object getVariable(String name) { Object value = variables.get(name); boolean definedHere = value != null || variables.containsKey(name); if (definedHere) return value; if ( value == null && isInherit() ) { JellyContext parentContext = getParent(); if (parentContext != null) { value = parentContext.getVariable( name ); } } // ### this is a hack - remove this when we have support for pluggable Scopes if ( value == null ) { value = getSystemProperty(name); } return value; }
/** * Populate a context with variables, including parent variables if inheritance is enabled. * * @param destContext the destination context * @param sourceContext the source context */ public static void populateVariables( JellyContext destContext, JellyContext sourceContext ) { if ( sourceContext != null ) { if ( !"false".equals( sourceContext.getVariable( "maven.property.inheritance" ) ) && ( !"false".equals( destContext.getVariable( "maven.property.inheritance" ) ) ) ) { populateVariables( destContext, sourceContext.isInherit() ? sourceContext.getParent() : null ); } destContext.getVariables().putAll( sourceContext.getVariables() ); } destContext.setVariable( "context", destContext ); } }
script = (Script) c.getVariables().get("org.apache.commons.jelly.body"); if(script!=null) break; c = c.getParent();