You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Daniel Pfeifer <Da...@tradedoubler.com> on 2006/05/31 06:00:13 UTC
Global variables
Hi,
this must be a frequent question but I couldn't find an answer to it on the website.
I've got following velocity template:
#set ($tempLink = "http://${subdomain}.tradedoubler.com/tr?a=${aId}&c=${cId}")
#if ($pId)
#set ($tempLink = $tempLink + "&p=${pId}")
#end
#if ($preurl)
#set ($tempLink = $preurl + $tempLink)
#end
$!{tempLink}
The fact of the matter is: Even though neither $pId or $preurl is null (I verified this and yes, it does enter the #if-blocks) the resulting tempLink is always
http://se.tradedoubler.com/tr?a=239&c=39433
The question is: Why don't the subsequent #set-directives change the value of $tempLink?
Thanks in advance,
Daniel Pfeifer
Re: Global variables
Posted by Nathan Bubna <nb...@gmail.com>.
sorry, + is for math, not string concatenation.
also, for building links in webapps, you might consider using
VelocityTools. It has a very handy LinkTool.
http://jakarta.apache.org/velocity/tools/view/LinkTool.html
On 5/30/06, Daniel Pfeifer <Da...@tradedoubler.com> wrote:
>
> Hi,
>
> this must be a frequent question but I couldn't find an answer to it on the website.
>
> I've got following velocity template:
>
> #set ($tempLink = "http://${subdomain}.tradedoubler.com/tr?a=${aId}&c=${cId}")
> #if ($pId)
> #set ($tempLink = $tempLink + "&p=${pId}")
> #end
> #if ($preurl)
> #set ($tempLink = $preurl + $tempLink)
> #end
> $!{tempLink}
>
>
> The fact of the matter is: Even though neither $pId or $preurl is null (I verified this and yes, it does enter the #if-blocks) the resulting tempLink is always
>
> http://se.tradedoubler.com/tr?a=239&c=39433
>
> The question is: Why don't the subsequent #set-directives change the value of $tempLink?
>
> Thanks in advance,
> Daniel Pfeifer
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Global variables
Posted by trad-ex <tr...@inter7.jp>.
Hi, Daniel,
Try it below !
#set($tempLink = "$!preurl$tempLink$!pId")
Best Regards
trad-ex
>
>Hi,
>
>this must be a frequent question but I couldn't find an answer to it on the
> website.
>
>I've got following velocity template:
>
>#set ($tempLink = "http://${subdomain}.tradedoubler.com/tr?a=${aId}&c=${cId
>}")
>#if ($pId)
> #set ($tempLink = $tempLink + "&p=${pId}")
>#end
>#if ($preurl)
> #set ($tempLink = $preurl + $tempLink)
>#end
>$!{tempLink}
>
>
>The fact of the matter is: Even though neither $pId or $preurl is null (I
>verified this and yes, it does enter the #if-blocks) the resulting tempLink
> is always
>
>http://se.tradedoubler.com/tr?a=239&c=39433
>
>The question is: Why don't the subsequent #set-directives change the value
>of $tempLink?
>
>Thanks in advance,
>Daniel Pfeifer
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org