velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nathan Bubna" <nbu...@gmail.com>
Subject Re: Injecting properties into Velocity...
Date Wed, 03 Dec 2008 17:48:34 GMT
You can put a ResourceBundle directly into your context:

context.put("labels", ResourceBundle.getBundle("labels"));

and then do

$labels.getString('username')

or you can put a java.util.Properties in and just use $props.get('username')

or you can use VelocityTools' ResourceTool class.  For this, you can
either use the VelocityTools infrastructure to put it into the context
or do something like:

context.put("text", new ResourceTool().bundle("labels"));

and then do

$text.username


On Wed, Dec 3, 2008 at 9:28 AM, carlo latasa <clatasa@gmail.com> wrote:
> Hello
>
> I'm trying to get velocity to use a properties file of mine that has
> customized labels. This is so I can call a velocity tag like : #stextfield(
> "label='member.username.label'" "name='username'" "size=25") where the label
> value would be defined in the properties file.
>
> Is it just a matter of putting the properties into some kind of static
> Velocity class somewhere?
>
> Thanks in advance,
>
> Carlo
>

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


Mime
View raw message