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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]