You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Dumitru Postoronca <du...@1and1.ro> on 2007/12/28 16:30:18 UTC
Printf-like method in Velocity
Hello & Happy new year :),
I'm working on a project that involves SpringMVC+Velocity and I'm trying
to use internationalization in a specific way:
Basically what I want to do in a Velocity template is something like this:
System.out.printf(myLocalizedMsg, foo)
where myLocalizedMsg=Text1 %s text2
I've looked at #springMessage macro but doesn't allow for printf-like
parameters, also, I haven't found a way to make Velocity run a simple
System.out.print("test") in the template so it looks like you can't
access static methods from template.
Is there any way to accomplish something like this in Velocity view or I
have to do it in the controller?
Thank you.
--
Best regards,
Dumitru Postoronca
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Printf-like method in Velocity
Posted by Claude Brisson <cl...@renegat.net>.
Yes, or you can also check
http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/ResourceTool.html
if it fulfills your needs.
Claude
Le vendredi 28 décembre 2007 à 09:55 -0800, Will Glass-Husain a écrit :
> You can make a tool to do this. Specifically, create an object with a
> public method, then call that method from your template.
>
> WILL
>
> On Dec 28, 2007 7:30 AM, Dumitru Postoronca <du...@1and1.ro> wrote:
> > Hello & Happy new year :),
> >
> > I'm working on a project that involves SpringMVC+Velocity and I'm trying
> > to use internationalization in a specific way:
> > Basically what I want to do in a Velocity template is something like this:
> > System.out.printf(myLocalizedMsg, foo)
> > where myLocalizedMsg=Text1 %s text2
> >
> > I've looked at #springMessage macro but doesn't allow for printf-like
> > parameters, also, I haven't found a way to make Velocity run a simple
> > System.out.print("test") in the template so it looks like you can't
> > access static methods from template.
> > Is there any way to accomplish something like this in Velocity view or I
> > have to do it in the controller?
> >
> > Thank you.
> >
> > --
> > Best regards,
> > Dumitru Postoronca
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> > For additional commands, e-mail: user-help@velocity.apache.org
> >
> >
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Printf-like method in Velocity
Posted by Will Glass-Husain <wg...@gmail.com>.
You can make a tool to do this. Specifically, create an object with a
public method, then call that method from your template.
WILL
On Dec 28, 2007 7:30 AM, Dumitru Postoronca <du...@1and1.ro> wrote:
> Hello & Happy new year :),
>
> I'm working on a project that involves SpringMVC+Velocity and I'm trying
> to use internationalization in a specific way:
> Basically what I want to do in a Velocity template is something like this:
> System.out.printf(myLocalizedMsg, foo)
> where myLocalizedMsg=Text1 %s text2
>
> I've looked at #springMessage macro but doesn't allow for printf-like
> parameters, also, I haven't found a way to make Velocity run a simple
> System.out.print("test") in the template so it looks like you can't
> access static methods from template.
> Is there any way to accomplish something like this in Velocity view or I
> have to do it in the controller?
>
> Thank you.
>
> --
> Best regards,
> Dumitru Postoronca
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
--
Forio Business Simulations
Will Glass-Husain
wglass@forio.com
www.forio.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: Printf-like method in Velocity
Posted by Nathan Bubna <nb...@gmail.com>.
Could be a cool to add a print(msg, args) method(s) to the DisplayTool
(in VelocityTools 2). I'll try to remember this...
On Dec 28, 2007 7:30 AM, Dumitru Postoronca <du...@1and1.ro> wrote:
> Hello & Happy new year :),
>
> I'm working on a project that involves SpringMVC+Velocity and I'm trying
> to use internationalization in a specific way:
> Basically what I want to do in a Velocity template is something like this:
> System.out.printf(myLocalizedMsg, foo)
> where myLocalizedMsg=Text1 %s text2
>
> I've looked at #springMessage macro but doesn't allow for printf-like
> parameters, also, I haven't found a way to make Velocity run a simple
> System.out.print("test") in the template so it looks like you can't
> access static methods from template.
> Is there any way to accomplish something like this in Velocity view or I
> have to do it in the controller?
>
> Thank you.
>
> --
> Best regards,
> Dumitru Postoronca
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org