velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthias Hendler" <hendl...@gmx.de>
Subject Re: Re: Putting key/value pair into hashmap from velocity template
Date Fri, 21 Jul 2006 13:42:27 GMT
Thanx Will,

thats what I didn't know.

The reference exception was caused by the return value of put, not by the template syntax.

What solves this problem is to surpress the return value by velcoity.
5. $!jMap.put("key", "value")        ## return value "null" is now surpressed


Cheers
Matthias




-------- Original-Nachricht --------
Datum: Fri, 21 Jul 2006 06:10:26 -0700
Von: Will Glass-Husain <wglass@forio.com>
An: Velocity Users List <velocity-user@jakarta.apache.org>
Betreff: Re: Putting key/value pair into hashmap from velocity template

> Hi Matthias--
> 
> Two things.  First, this syntax is not valid:
> ${jMap.put("tttt123", "test")}
> 
> Use one of these two forms this instead
> 
> $jMap.put("ttt123","test")
> ${jMap}.put("ttt123","test")
> 
> Second, the "put" call works fine in your example.  But since it returns 
> null, it echoes back the velocity reference.   You can test this by 
> doing a get after the put.
> 
> The reason Velocity works this way is that templates are typically used 
> to just display data.  They very rarely change internal state.  (makes 
> for less error-prone programming).  If you want to call "put" from 
> within your template and not have it return null, you'll need to write a 
> Map wrapper which is either defined void or returns an actual value.
> 
> WILL
> 
> 
> Matthias Hendler wrote:
> > Hello,
> >
> > I have created a simple test to show the problem I have with velocity.
> > I offer my test case in a zip archive to everyone who is interested.
> >
> > Download the archive at: http://velocity.hendler<replace this and
> brackets by a minus sign '-'>home.de/
> >
> > In this archive you will find the java source, all needed velocity jars,
> a template and a batch file to run the test.
> > Look at my template file, run the batch file and watch the output file
> and velocity logfile.
> >
> > I would be pleased if anyone could tell me what I am doing wrong!
> >
> >
> >
> >   
> 
> -- 
> Forio Business Simulations
> 
> Will Glass-Husain
> phone (415) 440-7500 x89
> mobile (415) 235-4293
> wglass@forio.com
> www.forio.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org

-- 


Echte DSL-Flatrate dauerhaft für 0,- Euro*. Nur noch kurze Zeit!
"Feel free" mit GMX DSL: http://www.gmx.net/de/go/dsl

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message