Hi all,

I'm having a strange problem with Velocity. I use my own implementation of
Map interface, let's say it looks like this:

public class Params extends HashMap<String, String>
{
        public Params()
        {
                put("a", "aaa");
        }

        @Override
        public String get(Object key)
        {
                return super.get(key);
        }
}

Very simple for the sake of example. Now I add this map to velocity context
and run the engine:

    public static void main( String[] args )
        throws Exception
    {
        VelocityEngine engine = new VelocityEngine();
        engine.init();
                VelocityContext context = new VelocityContext();
                context.put("params", new Params());

                StringWriter result = new StringWriter();
                String template = "${params.get(\"a\")}";
                engine.evaluate(context, result, "", template );
                System.out.println(result.toString());
    }

My output is this: ${params.get("a")}
instead of this: aaa

What is the most strange to me, is that the example works fine if I remove
the get method from the Params class, even though the override method does
nothing but call the super method.
Can anyone tell me what's going on?


Thanks!
Mateusz Matela
-- 
View this message in context: 
http://old.nabble.com/Can%27t-acces-map-values-when-get%28%29-is-overriden-tp31955214p31955214.html
Sent from the Velocity - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to