velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From George.MANTZA...@ext.cec.eu.int
Subject RE: Creating HashMaps from within the template for temporary proc essing
Date Fri, 28 Jul 2006 09:14:23 GMT
Hello Matthias,

Thank you very much for your hints.
Actually my situation is the following:

I have a large cache where I keep a lot of indexed news.
This cache is updated regularly from a database whith a sceduler.
Then there is a class which grabs specific news and creates rss and xml
files.
The velocity contexts are feeded mostly by java lists which contain objects.
So in the template am using the objects get methods to get particular
attributes.
Its true that some files are almost 5MB so all the process of the template
looping through the
Lists and using the get methods it's a bit slow. Maybe it's the way am
constructing the objects...
Are you using class resource loader? Me am using file, maybe this is also a
drawback?

Best regards

Georgios Mantzakos




-----Original Message-----
From: Matthias Hendler [mailto:hendler2@gmx.de] 
Sent: Friday, July 28, 2006 9:11 AM
To: Velocity Users List; velocity-user@jakarta.apache.org
Subject: Re: Creating HashMaps from within the template for temporary
processing


Hello,

I think the only solution is to create the instance of the map in java.
Then put the instance into the velocity context.
Thats it.


As I faced the same problem, I have written my own java class to start
velocity.
Then I have a property to instantiate HashMaps and ArrayList in this class
which will be added to the velocity context. After a template was processed,
the Maps and Lists are cleared by my java class.
(But you can also clear the Maps/Lists in the template before using them.)

Well, I dont know how this approach will work with the velocity resource
loaders. I use velocity to generate plsql code from templates and therefore
I read the template files by myself.


Matthias













-------- Original-Nachricht --------
Datum: Thu, 27 Jul 2006 16:43:04 +0530
Von: Santosh Puranshettiwar <santosh@wirkle.com>
An: Velocity Users List <velocity-user@jakarta.apache.org>
Betreff: Creating HashMaps from within the template for temporary processing

> Hello everyone,
> 
> The situation goes like this.
> 
> 1. There runs a for loop based on which I need to keep record of a key 
> value pair.
> 2. Based on these key value pairs some more text is added later, outside 
> the for loop (in step1).
> 
> For example: -
> #foreach( $person in $person_list )
> $person.name
> #if( $person.details )
> #set( $hyperLink = ${person.name}details )
> #set( $personDetailsMap.put(${person.name}details, $person.details)
> <a href="$hyperLink">Details</a>
> #end
> #end
> 
> #set( $perseonDetailKeyList  = $personDetailsMap.keySet() )
> #foreach( $personDetail in $personDetailKeyList )
> <a name="person.html#$personDetail">$personDetail</a>
> 
> ##Person details go here
> 
> #end
> 
> 
> The only difficulty I am facing here is, how do I instantiate 
> $personDetailsMap within the velocity template.
> 
> Thanks,
> Santosh.
> 
> ---------------------------------------------------------------------
> 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

---------------------------------------------------------------------
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