velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Assia Aouat" <as...@canada.sirsi.com>
Subject RE: Constant values as Velocimacro parameters
Date Tue, 12 Oct 2004 16:38:17 GMT
Try to rename the variables ! 

#macro( optionValue $currentValue $defaultValue )
        #set( $currentValue2 = $currentValue.toString() )
        #set( $defaultValue2 = $defaultValue.toString() )

        #if ( $defaultValue2.equals( $currentValue2 ) )
                selected
		#end
        value="$defaultValue2"
#end

hope that will help 

-----Original Message-----
From: Justin Akehurst [mailto:akehurst@gmail.com] 
Sent: Tuesday, October 12, 2004 12:33 PM
To: Velocity List
Subject: Constant values as Velocimacro parameters
Importance: Low

I have the following Velocimacro defined:

#macro( optionValue $currentValue $defaultValue )
        #set( $currentValue = $currentValue.toString() )
        #set( $defaultValue = $defaultValue.toString() )

        #if ( $defaultValue.equals( $currentValue ) )
                selected
		#end
        value="$defaultValue"
#end

And I am calling this macro like so:
#set $foo="-1"
<option #optionValue($foo "50") >Bar Baz</option>

When the page is rendered, velocity.log has this error message:

Tue Oct 12 15:25:00 GMT 2004  [error] VMProxyArg.setObject() :
Programmer error : I am a constant!  No setting! : defaultValue / '50'

Is the syntax I am using above illegal or could it be done a different
way as to avoid the error in the log above?

-Justin Akehurst

---------------------------------------------------------------------
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


Mime
View raw message