Refine search
private Object evalAttribute(String name, JellyContext context) { ExpressionAttribute e = attributes.get(name); if (e==null) return null; return e.exp.evaluate(context); }
actual.addAttribute("",name,name,"CDATA",expression.evaluateAsString(context)); output.endElement(tagName); } catch (SAXException x) { throw new JellyTagException(x);
public void run(JellyContext context, XMLOutput output) throws JellyTagException { String var = getAttribute("var").evaluateAsString(context); Object target = getAttribute("target").evaluate(context); String property = getAttribute("property").evaluateAsString(context); throw new JellyTagException("The 'target' and 'property' attributes cannot be used in combination with the 'var' attribute"); throw new JellyTagException("Either a 'var' or a 'target' attribute must be defined for this tag"); throw new JellyTagException("The 'target' attribute requires the 'property' attribute"); answer = value.exp.evaluate(context); ExpressionAttribute defaultValue = attributes.get("defaultValue"); answer = defaultValue.exp.evaluate(context); answer = getBodyText(context,getAttribute("encode").evaluateAsBoolean(context)); String scope = getAttribute("scope").evaluateAsString(context); if (scope != null) { context.setVariable(var, scope, answer); } else { context.setVariable(var, answer);
/** Evaluates the body of a tag */ public void run(JellyContext context, XMLOutput output) throws JellyTagException { Object result = expression.evaluate(context); if ( result != null ) { try { output.objectData(result); } catch (SAXException e) { throw new JellyTagException("Could not write to XMLOutput",e); } } } }
/** * Evaluates this tag after all the tags properties have been initialized. * */ public void doTag(XMLOutput output) throws JellyTagException { Object basenameInput = null; if (this.basename != null) { basenameInput = this.basename.evaluate(context); } LocalizationContext locCtxt = BundleTag.getLocalizationContext( context, (String) basenameInput); String varname = (var != null) ? var : Config.FMT_LOCALIZATION_CONTEXT; if (scope != null) { context.setVariable(varname, scope, locCtxt); } else { context.setVariable(varname, locCtxt); } }
public Object evaluate(JellyContext context) { Object answer = jexlExpression.evaluate(context); if ( answer == null ) { answer = context.getVariable(text); } return answer; }
public void doTag(XMLOutput output) throws BreakException { boolean broken = false; if (test == null || test.evaluateAsBoolean(context)) { broken = true; } if ( var != null ) { context.setVariable( this.var, String.valueOf(broken)); } if ( broken ) { throw new BreakException(); } }
Iterator iter = items.evaluateAsIterator(context); Integer statusStep = (step == 1) ? null : new Integer(step); status = new LoopStatus(statusBegin, statusEnd, statusStep); context.setVariable(statusVar, status); Object value = iter.next(); if (var != null) { context.setVariable(var, value); context.setVariable(indexVar, new Integer(index));
URL rootURL = context.getRootURL(); URL currentURL = context.getCurrentURL(); final Object oldParent=context.getVariables().get(PARENT_TAG); try { Tag tag = getTag(context); value = expression.evaluateRecurse(context); value = expression.evaluateRecurse(context);
/** * Adds {@link XMLOutput} to the context. */ public void run(JellyContext context, XMLOutput output) throws JellyTagException { context.setVariable(getAttribute("var").evaluateAsString(context),output); } };
@Override protected Script resolveDefinition(JellyContext context) throws JellyTagException { Object it = expr.evaluate(context); if (it==null) throw new JellyTagException("'"+ expr.getExpressionText() +"' evaluated to null"); try { WebApp webApp = WebApp.getCurrent(); MetaClass c = webApp.getMetaClass(it instanceof Class ? Klass.java((Class)it): webApp.getKlass(it)); // prefer 'foo.jellytag' to avoid tags from showing up as views, // but for backward compatibility, support the plain .jelly extension as well. Script tag = c.loadTearOff(JellyClassTearOff.class).findScript(tagName+".jellytag"); if (tag==null) tag = c.loadTearOff(JellyClassTearOff.class).findScript(tagName+".jelly"); if (tag ==null) throw new JellyTagException("No such tag file "+tagName+".jellytag in "+c); return tag; } catch (JellyException e) { throw new JellyTagException("Failed to load "+tagName+".jellytag from "+it,e); } } };
public void doTag(XMLOutput output) throws JellyTagException { ChooseTag tag = (ChooseTag) findAncestorWithClass( ChooseTag.class ); if ( tag == null ) { throw new JellyTagException( "This tag must be enclosed inside a <choose> tag" ); } if ( ! tag.isBlockEvaluated() && test != null ) { if ( test.evaluateAsBoolean( context ) ) { tag.setBlockEvaluated(true); invokeBody(output); } } }
public void doTag(XMLOutput output) throws MissingAttributeException { if (var != null) { context.removeVariable( var.evaluateAsString(context) ); } else { throw new MissingAttributeException("var"); } }
public String evaluateAsString(JellyContext context) { StringBuffer buffer = new StringBuffer(); for (Iterator iter = expressions.iterator(); iter.hasNext(); ) { Expression expression = (Expression) iter.next(); String value = expression.evaluateAsString(context); if ( value != null ) { buffer.append( value ); } } return buffer.toString(); }
public void doTag(XMLOutput output) throws JellyTagException { if (test == null && xpath == null) { throw new MissingAttributeException( "test" ); } if (test != null) { if (! test.evaluateAsBoolean(context)) { fail( getBodyText(), "evaluating test: "+ test.getExpressionText() ); } } else { try { Object xpathContext = getXPathContext(); if (! xpath.booleanValueOf(xpathContext)) { fail( getBodyText(), "evaluating xpath: "+ xpath ); } } catch (JaxenException anException) { throw new JellyTagException("Error evaluating xpath", anException); } } }
public Object evaluate(JellyContext context) { context = new CustomJellyContext(context); context.setVariables(resourceLiterals); return innerExpression.evaluate(context); } }
public void doTag(XMLOutput output) throws JellyTagException { String message = getBodyText(); Object expectedValue = expected.evaluate(context); Object actualValue = actual.evaluate(context); if (expectedValue == null && actualValue == null) { return; } if (actualValue != null && expectedValue.equals(actualValue)) { return; } String expressions = "\nExpected expression: " + expected.getExpressionText() + "\nActual expression: " + actual.getExpressionText(); failNotEquals(message, expectedValue, actualValue, expressions); }
public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException { if (test != null) { if (test.evaluateAsBoolean(context)) { invokeBody(output); } } else { throw new MissingAttributeException( "test" ); } }
public String getExpressionText() { return base.getExpressionText(); }
public Object evaluateRecurse(JellyContext context) { Object value = evaluate(context); if (value instanceof Expression) { Expression expression = (Expression) value; return expression.evaluateRecurse(context); } return value; }