View Full Version : passing arguments to #springMessage ???
Miel
Jul 4th, 2006, 09:31 AM
Seen a lot of topics here concerning argument passing to the spring message tags...
I was wondering if the same is possible for the #springMessage macro...
(in other words, replacing the {0}, {1} ... {n} from within a velocity template)
Miel
Jul 5th, 2006, 10:02 AM
Issue solved...
Impatient as i am, i went goofing around in spring.vm a bit...
and added my own macro to do the things i wanted....
For those that have the same issue:
Add:
#macro( springArgMessage $code $args )
$springMacroRequestContext.getMessage($code, $args)
#end
to the following file:
%SPRINGDIR%\src\org\springframework\web\servlet\vi ew\velocity\spring.vm
Usage:
$set( $args = ["argument1","argument2"] )
$springArgMessage( "message.name" $args )
btw. is there any way to define a list inline with the macro call?
$springArgMessage( "message.name" ["argument1","argument2"] )
for instance, does not work, and since most of the messages have only one argument, it would be nice to work around setting the list var every time...
sammy13
May 23rd, 2013, 06:49 AM
The #springMessageText has the same implementation, so you don't have to implement it again. However its documentation says about default text, you can use it for this purpose as well:
#springMessageText("message.key" [$arg0, $arg1, ...])
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.