velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Will Glass-Husain" <wgl...@forio.com>
Subject Re: Can velocity load a properties file ?
Date Thu, 20 Apr 2006 20:42:12 GMT
Are you sure?  I think #set can be used for any class.

I've proposed to limit this to prohibit reflection by default (such as what
trad-ex is doing), but we haven't applied the patch yet.

WILL

On 4/20/06, Barbara Baughman <baughman@utdallas.edu> wrote:
>
> You cannot use the #set directive to designate just any kind of JAVA
> object.  See the User Guide for allowable references.  I believe the
> #set directive you have will automatically call the toString method of
> the class in order to set the variable to a valid reference, but you
> can check by printing the value of the set variable.
>
> Barbara Baughman
> X2157
>
> On Thu, 20 Apr 2006, trad-ex wrote:
>
> > Hi All,
> >
> > I tried to load property resource bundle file, but failed to get an
> > instance of FileInputStream.
> > My code is below:
> >
> > #set( $fStreamClass = $util.class.forName("java.io.FileInputStream") )
> > #set( $iStreamClass = $util.class.forName("java.io.InputStream") )
> > #set( $stringClass = $util.class.forName("java.lang.String") )
> > #set( $bundleClass
> >      = $util.class.forName("java.util.PropertyResourceBundle") )
> > #set( $userNameFilePath = $util.getPortalFile($userNameFile) )
> > #set( $resStream
> >      = $fStreamClass.getConstructor( [$stringClass] )
> >        .newInstance( ["$userNameFile"] ) )
> > #set( $resBundle
> >      = $bundleClass.getConstructor( [$iStreamClass] )
> >      .newInstance( [$resStream] ) )
> >
> > $util object is provided by our application to inject functionality into
> > velocity context.
> > I succeeded to get $fStreamClass & $iStreamClass & $bundleClass
> > But I failed to get $resStream & $resBundle.
> >
> > My questions are:
> > 1. Can I load the specific property file in Velocity context ?
> > 2. What's wrong with my velocity script ?
> >
> > Best Regards, and thanks in advance.
> > trad-ex
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>


--
Forio Business Simulations

Will Glass-Husain
wglass@forio.com
www.forio.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message