PropertyHandlerFactory.setNullPropertyHandler(new PropertyHandler() {
public Object getProperty(String name, Object contextObj,
VariableResolverFactory variableFactory) {
List someList = new ArrayList();
someList.add(new Foo());
return someList;
}
public Object setProperty(String name, Object contextObj,
VariableResolverFactory variableFactory, Object value) {
return null;
}
});
PropertyHandlerFactory.registerPropertyHandler(List.class, new
PropertyHandler() {
public Object getProperty(String name, Object contextObj,
VariableResolverFactory variableFactory) {
List list = (List) contextObj;
int index = Integer.valueOf(name);
while (index >= list.size()) {
list.add(new Foo());
}
return list.get(index);
}
public Object setProperty(String name, Object contextObj,
VariableResolverFactory variableFactory, Object value) {
return null;
}
});
Foo foo = new Foo();
final Serializable fooExpr0 =
MVEL.compileSetExpression("collectionTest[0].name");
final Serializable fooExpr1 =
MVEL.compileSetExpression("collectionTest[1].name");