velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geir Magnusson Jr. <ge...@adeptra.com>
Subject Re: hash map or equivalent possible
Date Thu, 19 Dec 2002 18:29:54 GMT

On Thursday, December 19, 2002, at 12:22 PM, Bill Kaufman wrote:

> (One amendment: the file might not be called "toolbox.xml".  That's 
> specified in WEB-INF/web.xml, under a parameter named "toolbox".  I 
> suspect most people name it "toolbox.xml" anyway, but if you can't 
> find it by that name, look in web.xml.)
>
> As long as the code they're using derives from VelocityViewServlet, 
> you should be able to extract toolbox.xml from their WAR file (using 
> "jar -xf" or WinZip), make the changes I described, and put 
> toolbox.xml and the Java class file back into the WAR file (using "jar 
> -uf").

I'd be very surprised if they were.

>
> If they're not using VelocityViewServlet, well, they really should 
> have given you some way to extend the system, and I'd kvetch to them 
> about it.
>
> If you're not sure whether or not they're using VelocityViewServlet, 
> you'd need to:
>
>     1) look at their WEB-INF/web.xml to find out their servlet 
> class(es) (in the <servlet-class> tag(s));
>     2) add the WAR file to your CLASSPATH variable; and,
>     3) do "javap" on each of the servlet classes to see whether they 
> subclass from VelocityViewServlet.
>
> (Yeah, there really ought to be an easier way,...)
>

Are they using servlets?  If not, you might take the velocity source, 
change the VelocityContext to put a empty map in it for you, and use 
that jar :)


>                                                       -- Bill K.
>
>
>> -----Original Message-----
>> From: Charlene Mitchell [mailto:charlene_ml@yahoo.co.uk]
>> Sent: Thursday, December 19, 2002 9:04 AM
>> To: Velocity Users List
>> Subject: RE: hash map or equivalent possible
>>
>>
>> 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>
>
>
> --
> To unsubscribe, e-mail:   
> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: 
> <mailto:velocity-user-help@jakarta.apache.org>
>
>
-- 
Geir Magnusson Jr                                   203-355-2219(w)
Adeptra, Inc.                                       203-247-1713(m)
geirm@adeptra.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