velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wojtek Rappak" <rat...@nildram.co.uk>
Subject RE: Setting application-scope properties in velocity servlet
Date Fri, 12 Jul 2002 14:36:39 GMT
Thanks for clarifying this.

I am indeed using the servlet API and coding this as:

		getServletContext().setAttribute("regforms",regforms );
         	regforms = (RegForms)
getServletContext().getAttribute("regforms");

However, I wanted to put this into Velocity because this is data *about*
application data which I want to make available to the application code (eg
what formfields make up a certain form for a brand).  This code in turn
prepares the formbeans used by VTL expressions. I started putting this into
the existing properties file and it quickly became obvious that *this*
meta-data is of a  type that is different from that for which the properties
file is intended.

So - accepting your point about no application data in Velocity - I think
that it would be a good idea to have a 'getAppAtt()' to allow for cases
where an application needs to extend the configuration data in some way.

Wojtek Rappak

> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@adeptra.com]
> Sent: 12 July 2002 14:41
> To: velocity-user@jakarta.apache.org
> Subject: Re: Setting application-scope properties in velocity servlet
>
>
> On 7/12/02 9:34 AM, "Wojtek Rappak" <ratcom@nildram.co.uk> wrote:
>
> > Am I missing something basic?
> >
> > Why doesn't this bit of code work?  I've put it at the end of
> an overriding
> > initVelocity() method in my servlet code:
> >
> >
> >          Velocity.setProperty( "regforms",regforms );
> >          regforms = (RegForms) Velocity.getProperty( "regforms" );
> >
> > regforms is an object tree - that shouldn't make a difference.
> It holds form
> > configuration data and I want to have access to it from everywhere.   In
> > other words, it's just a simple case of a bit of config data
> which I want to
> > hold in the runtime singleton.
>
> Don't use Velocity's configuration API to hold your data :)
>
> Why can't you just use the servlet API?
>
> There is a 'setApplicationAttribute()' but there is no corresponding 'get'
> as this was intended to let you configure properties to send into custom
> components (which can read it).
>
> Maybe we add the getAppAtt(), but I still think that using the
> Velocity API
> for this is inappropriate.
>
>
>
>
> --
> Geir Magnusson Jr.
> Research & Development, Adeptra Inc.
> geirm@adeptra.com
> +1-203-247-1713
>
>
>
> --
> 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