velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthias Hendler" <>
Subject Re: Re: Putting key/value pair into hashmap from velocity template
Date Thu, 20 Jul 2006 08:24:52 GMT

thanx for the many answers.
What I forgot to mention is that I use Velocity 1.4.

I have tested a lot with my code before.

My java code looks like this:
final VelocityEngine ve = new VelocityEngine();
final VelocityContext context;
context = new VelocityContext();

context.put("myMap", new HashMap());
context.put("myList", new ArrayList());
context.put("myTable", new Hashtable());

// Velocity
final boolean success = ve.evaluate(context, writerVelocity, "Velocity", readerEscaped);

My template looks like this:
1. $myMap.toString()
2. $myMap.getClass()
3. $myMap.isEmpty()
4. ${myMap.put("tttt123", "test")}

Ouput of the template IF line 4 is "deleted".
1. {}
2. class java.util.HashMap
3. true

If line 4 is part of the template I sill get the invalid reference exception.

So, I did some testing around my problem.
1. $myList.set(0, "Hallo")
This works.

2. ${myMap.put("tttt123", "test")}
3. $myTable.put("test", "hallo")
both doesnt work.

Any ideas why it works in case 1 and not in case 2 and 3?


Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message