So, I've switched to mvel, primarily because I'd like to be able to call methods with arguments.
I've got a bean that looks like this:
public class Model {
List<Long> bars;
public boolean containsBar(Long id) {
return bars.contains(id);
}
}
And a template like this:
<div a:if="model.containsBar(1)"></div>
It seems like Cambridge is trying to execute things with PropertyUtils instead of just passing the data to mvel to process. The exception I get looks like this:
Caused by: java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
at cambridge.runtime.PropertyUtils.getBeanProperty(PropertyUtils.java:83)
at cambridge.parser.expressions.VarExpression.eval(VarExpression.java:70)
at cambridge.parser.expressions.VarExpression.asBoolean(VarExpression.java:90)
at cambridge.behaviors.ConditionalTagBehavior.conditionMet(ConditionalTagBehavior.java:36)
at cambridge.model.TagNode.conditionsMet(TagNode.java:823)
at cambridge.model.TagNode.eval(TagNode.java:632)
at cambridge.DynamicTemplate.printTo(DynamicTemplate.java:53)
Also, in code, how can I set mvel as the default template language? Right now, I have it set with <!--$expressionLanguage mvel --> at the top of my _body.html base template, but I'd rather just set it in java code.
You might want to add to the documentation that you need to register mvel in code like this:
Expressions.registerExpressionLanguage("mvel", MvelExpressionLanguage.class);
jon