velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Kaufman" <BKauf...@zaplet.com>
Subject RE: hash map or equivalent possible
Date Thu, 19 Dec 2002 14:59:00 GMT
> 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
> > Aquilent, Inc.
> > National Library of Medicine
> > 
> > 
> >
> __________________________________________________________________
> > The NEW Netscape 7.0 browser is now available.
> > Upgrade now!
> >
> http://channels.netscape.com/ns/browsers/download.jsp
> > 
> > 
> > Get your own FREE, personal Netscape Mail account
> > today at http://webmail.netscape.com/
> > 
> > --
> > 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>


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