You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by David Zhao <wz...@gmail.com> on 2006/11/30 00:19:03 UTC
setting missing argument to default in macro or overloading macro
Hi there,
Is there a way to either set a missing argument to a default value, or
overloading the macro?
for example, if I have a macro like this:
#macro (toBeOverLoaded $name $value $size)
#if ($size < 30)
#set ($size = 30)
#end
...
#end
and calling this macro:
#toBeOverLoaded($name $value), note: $size is not passed.
Is there any way I can do this?
Thanks,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: setting missing argument to default in macro or overloading macro
Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
"Will Glass-Husain" <wg...@forio.com> writes:
Well, there is velocimacro.arguments.strict which can be set to true/false.
Maybe this can help with the defaults.
Best regards
Henning
>Well, not really but there's a workaround. Use a List as a single parameter
>#macro(myMacro $listOfItems)
>blah blah $listOfItems.get(1) blah blah
>#end
>and call with
>#myMacro(["abc", "def"])
>WILL
>On 11/29/06, David Zhao <wz...@gmail.com> wrote:
>> Hi there,
>>
>> Is there a way to either set a missing argument to a default value, or
>> overloading the macro?
>> for example, if I have a macro like this:
>> #macro (toBeOverLoaded $name $value $size)
>> #if ($size < 30)
>> #set ($size = 30)
>> #end
>> ...
>> #end
>>
>> and calling this macro:
>> #toBeOverLoaded($name $value), note: $size is not passed.
>> Is there any way I can do this?
>> Thanks,
>>
>> David
>>
>>
>> ---------------------------------------------------------------------
>> 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
--
Henning P. Schmiedehausen -- hps@intermeta.de | J2EE, Linux,
91054 Buckenhof, Germany -- +49 9131 506540 | Apache person
Open Source Consulting, Development, Design | Velocity - Turbine guy
"Save the cheerleader. Save the world."
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: What does this exception mean???
Posted by Claude Brisson <cl...@renegat.net>.
There is already a macro with the same name (or the file containing the
macro has been parsed twice in the rendering process).
If you want to redefine a macro, you have to set this property in
velocity.properties:
velocimacro.permissions.allow.inline.to.replace.global = true
Claude
Le jeudi 30 novembre 2006 à 17:28 +0530, Manish a écrit :
> I am having problem displyaing a certain table in VTL, and there is apparently
> no error in the macro but I get this error -
>
> 2006-11-30 05:39:57 StandardContext[/tc] Velocity [warn] Velocimacro : VM
> addition rejected : dimbylevelq : inline not allowed to replace existing VM
>
> ANY help/pointers will be very helpful.
>
> - Manish
>
>
>
> ---------------------------------------------------------------------
> 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
What does this exception mean???
Posted by Manish <pr...@gmx.net>.
I am having problem displyaing a certain table in VTL, and there is apparently
no error in the macro but I get this error -
2006-11-30 05:39:57 StandardContext[/tc] Velocity [warn] Velocimacro : VM
addition rejected : dimbylevelq : inline not allowed to replace existing VM
ANY help/pointers will be very helpful.
- Manish
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
RE: setting missing argument to default in macro or overloading macro
Posted by Amit Jha <j_...@vtls.co.in>.
There is no way to do so but you can pass default value to it
#macro (Name $var1 $var2 $var3)
#statement1
#statement2
#end
call with
#Name(value1 '' '')
Name
-----Original Message-----
From: wglasshusain@gmail.com [mailto:wglasshusain@gmail.com] On Behalf
Of Will Glass-Husain
Sent: Thursday, November 30, 2006 10:11 AM
To: Velocity Users List
Subject: Re: setting missing argument to default in macro or overloading
macro
Well, not really but there's a workaround. Use a List as a single
parameter
#macro(myMacro $listOfItems)
blah blah $listOfItems.get(1) blah blah
#end
and call with
#myMacro(["abc", "def"])
WILL
On 11/29/06, David Zhao <wz...@gmail.com> wrote:
> Hi there,
>
> Is there a way to either set a missing argument to a default value, or
> overloading the macro?
> for example, if I have a macro like this:
> #macro (toBeOverLoaded $name $value $size)
> #if ($size < 30)
> #set ($size = 30)
> #end
> ...
> #end
>
> and calling this macro:
> #toBeOverLoaded($name $value), note: $size is not passed.
> Is there any way I can do this?
> Thanks,
>
> David
>
>
> ---------------------------------------------------------------------
> 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
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: setting missing argument to default in macro or overloading macro
Posted by Will Glass-Husain <wg...@forio.com>.
Well, not really but there's a workaround. Use a List as a single parameter
#macro(myMacro $listOfItems)
blah blah $listOfItems.get(1) blah blah
#end
and call with
#myMacro(["abc", "def"])
WILL
On 11/29/06, David Zhao <wz...@gmail.com> wrote:
> Hi there,
>
> Is there a way to either set a missing argument to a default value, or
> overloading the macro?
> for example, if I have a macro like this:
> #macro (toBeOverLoaded $name $value $size)
> #if ($size < 30)
> #set ($size = 30)
> #end
> ...
> #end
>
> and calling this macro:
> #toBeOverLoaded($name $value), note: $size is not passed.
> Is there any way I can do this?
> Thanks,
>
> David
>
>
> ---------------------------------------------------------------------
> 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