velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charlene Mitchell <charlene...@yahoo.co.uk>
Subject RE: hash map or equivalent possible
Date Thu, 19 Dec 2002 17:04:18 GMT
Hi,

I think (?) you missed the main problem I have,
which is:
"I cannot add it to the context as I only have access
 to Velocity templates and not to the Java code."

and I guess this also applies to toolbox.xml, unless
there is some way I can plonk it somewhere and get it
picked up automagically through a propery/env?

Charlene

 --- Bill Kaufman <BKaufman@zaplet.com> wrote: > >
Where would I get $map from in the first place?
> 
> You can create a tool which does this:
> 
> 1) Create a Java class, like,
> 
> -------- cut here --------
> import java.util.Map;
> import java.util.HashMap;
> 
> public class MapMakerTool {
>   public Map getMap() {
>     return new HashMap();
>   }
> }
> -------- cut here --------
> 
> 2) Add the class to your toolbox.xml:
> 
> -------- cut here --------
> <toolbox>
>   <!-- ...Your other tools,... -->
>   <tool>
>      <key>MapMaker</key>
>      <class>MapMakerTool</class>
>   </tool>
> </toolbox>
> -------- cut here --------
> 
> 3) Use the tool in your Velocity template, like,
> 
> -------- cut here --------
> #set ( $visited = $MapMaker.getMap() )
> #foreach ( $value in $SomeSortOfCollection )
>   #if ( !$visited.get($value) )
> 
>     #set ( $null = $visited.put($value, true) )
>     ## ... do your work here
> 
>   #end ## if we haven't seen this value before
> 
> #end ## for each value
> -------- cut here --------
> 
>                                                     
>  -- Bill K.
> 
> 
> > -----Original Message-----
> > From: Charlene Mitchell
> [mailto:charlene_ml@yahoo.co.uk]
> > Sent: Thursday, December 19, 2002 12:29 AM
> > To: Velocity Users List
> > Subject: RE: hash map or equivalent possible
> > 
> > 
> > Hi,
> > 
> > Where would I get $map from in the first place?
> > 
> > I cannot add it to the context as I only have
> access
> > to Velocity templates and not to the Java code.
> > 
> > Charlene
> > 
> >  --- plynchnlm@netscape.net wrote: > Would the
> > following work:
> > > 
> > > #if ($map.get($somKey))
> > >    ## Do something if $someKey is defined
> > > #end
> > > 
> > > But maybe I've misunderstood the question.
> > >   --Paul
> > > 
> > > Charlene Mitchell <charlene_ml@yahoo.co.uk>
> wrote:
> > > 
> > > >Hi,
> > > >
> > > >Thanks for reply.
> > > >
> > > >This is just during a single render of the
> > > application
> > > >
> > > >Thanks
> > > >
> > > >Charlene
> > > >--------
> > > >
> > > >PS - some more info:
> > > >Basically I'm looking at Objects and finding
> > > many2many
> > > >mappings and then inferring what the database
> join
> > > >table would be called....this means that I come
> at
> > > it
> > > >from both directions and see the same thing
> twice.
> > > >
> > > >e.g.
> > > >   Employee --> ADDRESS_EMPLOYEE
> > > >   Address  --> ADDRESS_EMPLOYEE
> > > >so when I come at it from the Address angle I
> need
> > > to
> > > >know it already exists.
> > > >
> > > > --- Charles Anthony
> > > <charles.anthony@hpdsoftware.com>
> > > >wrote: > Hi,
> > > >> 
> > > >> >In my Velocity template I need to keep a
> track
> > > of
> > > >> >whether or not a value has been seen before.
> > > >> 
> > > >> Do you mean during a single render of that
> > > template,
> > > >> or during
> > > >> any render of that template during the
> lifecycle
> > > of
> > > >> the application ?
> > > >> 
> > > >> Cheers,
> > > >> 
> > > >> Charles.
> > > >> 
> > > >> 
> > > >> This email and any attachments are strictly
> > > >> confidential and are intended
> > > >> solely for the addressee. If you are not the
> > > >> intended recipient you must
> > > >> not disclose, forward, copy or take any
> action in
> > > >> reliance on this message
> > > >> or its attachments. If you have received this
> > > email
> > > >> in error please notify
> > > >> the sender as soon as possible and delete it
> from
> > > >> your computer systems.
> > > >> Any views or opinions presented are solely
> those
> > > of
> > > >> the author and do not
> > > >> necessarily reflect those of HPD Software
> Limited
> > > or
> > > >> its affiliates.
> > > >> 
> > > >>  At present the integrity of email across the
> > > >> internet cannot be guaranteed
> > > >> and messages sent via this medium are
> potentially
> > > at
> > > >> risk.  All liability
> > > >> is excluded to the extent permitted by law
> for
> > > any
> > > >> claims arising as a re-
> > > >> sult of the use of this medium to transmit
> > > >> information by or to 
> > > >> HPD Software Limited or its affiliates.
> > > >> 
> > > >> 
> > > >> 
> > > >> --
> > > >> To unsubscribe, e-mail:  
> > > >>
> > >
> >
>
><mailto:velocity-user-unsubscribe@jakarta.apache.org>
> > > >> For additional commands, e-mail:
> > > >>
> <mailto:velocity-user-help@jakarta.apache.org>
> > > >>  
> > > >
> > >
> >__________________________________________________
> > > >Do You Yahoo!?
> > > >Everything you'll ever need on one web page
> > > >from News and Sport to Email and Music Charts
> > > >http://uk.my.yahoo.com
> > > >
> > > >--
> > > >To unsubscribe, e-mail:  
> > >
> >
>
<mailto:velocity-user-unsubscribe@jakarta.apache.org>
> > > >For additional commands, e-mail:
> > > <mailto:velocity-user-help@jakarta.apache.org>
> > > >
> > > >
> > > 
> > > 
> > > -- 
> > > Paul Lynch
> 
=== message truncated === 

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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


Mime
View raw message