> > It's those cases where java can execute a method but velocity can't see
> > it that I'm worried about. Apparently velocity ignores all methods in a
> > private classes, even if the methods themselves are public.
>
> I think it is intended behaviour to only allow invocation to public
> methods of public classes. You wouldn't be able to call other methods
> in java either (without reflection).
The only reason it doesn't work in java without reflection is because you
can't refer to an anonymous or private class. However, you can get the
class instance from an instance of such a class and use it to access the
method using relfection. In dynamically typed languages like velocity you
don't have this problem since they always get the class from the object.
That is, except in velocity where there are explicit checks to prevent
overcoming this problem.
It's very handy to do something like this:
final Database db=getDatabase();
context.put("user", new Object() {
// users have a name and a shoe
public String getName() {
return db.findName(USER_ID);
}
public Object getShoe() {
return new Object() {
// shoes have a size and a make
public int getSize() {
return db.findShoeSize(USER_ID);
}
public String getMake() {
return db.findShoeMake(USER_ID);
}
};
}
});
It gets a lot less attractive if you have to make these classes named, and
it gets really spaghetti if you had several nested anonymous classes (I
have only 1 nested class above) and have to flatten these out.
Well, I can just remove those checks from my own copy of velocity for my own
use.
Thanks.
- Marcus Sundman
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]