Hi Dimitrios,

> Velocity supports dynamic introspection (see class Uberspect for more
> details). If you want it to support such behaviour you should create
> your own introspection class (probably by copying-pasting from the
> default) and plug it into Velocity.
Curiosity kills cats and time...

Tried one.  Works when it's meant to work.  Haven't tested when it's
meant to fail, though.  ;)

public class PublicFieldUberspectImpl extends UberspectImpl {
    public VelPropertyGet getPropertyGet(Object obj, String identifier, Info i)
            throws Exception {
        VelPropertyGet getter = super.getPropertyGet(obj, identifier, i);
        try {
            getter.getMethodName();
            return getter;
        } catch (NullPointerException notFound) {
        }
        final Field field = obj.getClass().getField(identifier);
        if (field != null) {
            AbstractExecutor executor = new AbstractExecutor() {
                public Object execute(Object o) throws IllegalAccessException, 
InvocationTargetException {
                    return field.get(o);
                }
            };
            return new VelGetterImpl(executor);
        }
        return null;
    }
}

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <[EMAIL PROTECTED]>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to