You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Robert Douglass <r....@onlinehome.de> on 2003/10/04 11:57:19 UTC

RE: macros calling macros - the answer

It was a type conversion problem.

#macro( hyperlink $hyperlinkId)
####### THIS WORKS WHEN toString() IS CALLED
#set($hyperlinkDoc = $dataBase.getDocument($hyperlinkId.toString()))
$linkDoc
#end


-----Original Message-----
From: Robert Douglass [mailto:r.douglass@onlinehome.de]
Sent: Friday, October 03, 2003 10:12 PM
To: Velocity list
Subject: macros calling macros


I'm really sorry if the answer to this is in the mail archive, but I
couldn't find it.

#macro( hyperlink $hyperlinkId)
####### THIS SET DOESN'T WORK WHEN CALLED FROM NAVIGATION
#set($linkDoc = $dataBase.getDocument($hyperlinkId))
$linkDoc
#end

#macro( navigation $widgetId)
#set($navdoc = $dataBase.getDocument($widgetId))
#set($hyperlinks = $navdoc.applyDocumentPath('Hyperlinks'))
#foreach( $link in $hyperlinks )
#hyperlink($link.getIdValue())
#end
#end

I call #hyperlink from within #navigation. The variable $hyperlinkId and the
variable $dataBase are both right, but the line #set($linkDoc =
$dataBase.getDocument($hyperlinkId)) doesn't result in a method call. When I
call hyperlink directly, it works fine. Is can't be a type-conversion
problem -- getDocument(String id) -- as I use the same syntax elsewhere, so
I figure it must be a scoping/context problem. I've read the documentation,
and I've been on and off of this list for half a year, but alas, I just
don't understand.

Thanks in advance,

Robert Douglass


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


Re: String concatenation

Posted by Barbara Baughman <ba...@utdallas.edu>.
try
 #set($idImagen = $id)
 #set($idImagenBlank = "${id}_blank")
 #set($idImagenSrc = "${id}.src")
 #set($idImagenBlankSrc = "${id}_blank.src")
 #set($idImagenSrcValue = "$res_buttonPath$keyValue")


Barbara Baughman
X2157

On Mon, 6 Oct 2003, Guillermo Meyer wrote:

> I have a Velocity template that recives the following parameters:
>
> id
> keyValue
> res_buttomPath
>
> I want to concatenate some strings to be used in my template:
>
> #set($idImagen = $id)
> #set($idImagenBlank = $id"_blank")
> #set($idImagenSrc = $id".src")
> #set($idImagenBlankSrc = $id"_blank.src")
> #set($idImagenSrcValue = $res_buttonPath$keyValue)
>
> But I get the following error:
>
> org.apache.velocity.exception.ParseErrorException: Encountered "\"_blank\""
> at line 2, column 26.
> Was expecting one of:
> <RPAREN> ...
> <WHITESPACE> ...
> "-" ...
> "+" ...
> "*" ...
> "/" ...
> "%" ...
> "&&" ...
> "||" ...
> "<" ...
> "<=" ...
> ">" ...
> ">=" ...
> "==" ...
> "!=" ...
> <DOT> ...
> "=" ...
>
> What am I doing wrong? How do I concatenate 2 Strings?
>
> thanks in advance.
> Guillermo.
>
>
> ---------------------------------------------------------------------
> 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


String concatenation

Posted by Guillermo Meyer <gm...@sib.interbanking.com.ar>.
I have a Velocity template that recives the following parameters:

id
keyValue
res_buttomPath

I want to concatenate some strings to be used in my template:

#set($idImagen = $id)
#set($idImagenBlank = $id"_blank")
#set($idImagenSrc = $id".src")
#set($idImagenBlankSrc = $id"_blank.src")
#set($idImagenSrcValue = $res_buttonPath$keyValue)

But I get the following error:

org.apache.velocity.exception.ParseErrorException: Encountered "\"_blank\""
at line 2, column 26.
Was expecting one of:
<RPAREN> ...
<WHITESPACE> ...
"-" ...
"+" ...
"*" ...
"/" ...
"%" ...
"&&" ...
"||" ...
"<" ...
"<=" ...
">" ...
">=" ...
"==" ...
"!=" ...
<DOT> ...
"=" ...

What am I doing wrong? How do I concatenate 2 Strings?

thanks in advance.
Guillermo.


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org