You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Derek Stevenson <de...@retrocode.com> on 2002/08/12 21:28:02 UTC

Velocimacros calling velocimacros?

Hi,

I have the following defined in my GlobalMacros.vm:

#macro (sectionIndex)
	#foreach ( $sectionlink in $sgslocation.SectionIndex )
	  link:
	  #mochalink ( $sectionlink $sectionlink.Title )
	  <BR/>
	#end
#end

#macro (mochaLink $mochalink $linktitle)
	<A HREF="$link.setPage("$mochalink.VelocityURI").addPathInfo("action", 
"UpdateLocation").addQueryData("sectionpath", 
"$mochalink.SectionPath").addQueryData("pageid", 
"$mochalink.PageID")">$linktitle</A>
#end

However, when I call

#sectionIndex

from a screen I get the following output in my browser:

link: #mochalink ( Section [title='Intervention' index='1' 
path='bingeeating.bequiz-feedback.be-conseq1.intervention'] Intervention )
link: #mochalink ( Section [title='No Intervention' index='2' 
path='bingeeating.bequiz-feedback.be-conseq1.nointervention'] No 
Intervention )

It looks like Velocity is calling #sectionIndex fine but won't call 
#mochaLink in turn, rather it simply expands #sectionlink and 
#sectionlink.Title.  Is this expected behavior?  Is there a flag somewhere 
that allows me to call macros from other macros?  Or is this sort of 
functionality not supported, e.g. implement all behavior in sectionIndex 
rather than calling mochaLink in turn?

Thanks,
Derek


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Velocimacros calling velocimacros?

Posted by Peter Romianowski <me...@gmx.de>.
Hi Derek,

you have to define the mochaLink-macro prior the sectionIndex-macro.
As I recall Velocity does not support forward-declarations of macros

Peter

-----Original Message-----
From: Derek Stevenson [mailto:derek@retrocode.com] 
Sent: Monday, August 12, 2002 9:28 PM
To: velocity-user@jakarta.apache.org
Subject: Velocimacros calling velocimacros?


Hi,

I have the following defined in my GlobalMacros.vm:

#macro (sectionIndex)
	#foreach ( $sectionlink in $sgslocation.SectionIndex )
	  link:
	  #mochalink ( $sectionlink $sectionlink.Title )
	  <BR/>
	#end
#end

#macro (mochaLink $mochalink $linktitle)
	<A
HREF="$link.setPage("$mochalink.VelocityURI").addPathInfo("action", 
"UpdateLocation").addQueryData("sectionpath", 
"$mochalink.SectionPath").addQueryData("pageid", 
"$mochalink.PageID")">$linktitle</A>
#end

However, when I call

#sectionIndex

from a screen I get the following output in my browser:

link: #mochalink ( Section [title='Intervention' index='1' 
path='bingeeating.bequiz-feedback.be-conseq1.intervention'] Intervention
)
link: #mochalink ( Section [title='No Intervention' index='2' 
path='bingeeating.bequiz-feedback.be-conseq1.nointervention'] No 
Intervention )

It looks like Velocity is calling #sectionIndex fine but won't call 
#mochaLink in turn, rather it simply expands #sectionlink and 
#sectionlink.Title.  Is this expected behavior?  Is there a flag
somewhere 
that allows me to call macros from other macros?  Or is this sort of 
functionality not supported, e.g. implement all behavior in sectionIndex

rather than calling mochaLink in turn?

Thanks,
Derek


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Velocimacros calling velocimacros?

Posted by Derek Stevenson <de...@retrocode.com>.
Duh.  Changed mochalink to mochaLink and all works great.  Sorry for the chaff.

Cheers,
Derek

At 12:28 PM 8/12/2002, you wrote:
>Hi,
>
>I have the following defined in my GlobalMacros.vm:
>
>#macro (sectionIndex)
>         #foreach ( $sectionlink in $sgslocation.SectionIndex )
>           link:
>           #mochalink ( $sectionlink $sectionlink.Title )
>           <BR/>
>         #end
>#end
>
>#macro (mochaLink $mochalink $linktitle)
>         <A 
> HREF="$link.setPage("$mochalink.VelocityURI").addPathInfo("action", 
> "UpdateLocation").addQueryData("sectionpath", 
> "$mochalink.SectionPath").addQueryData("pageid", 
> "$mochalink.PageID")">$linktitle</A>
>#end
>
>However, when I call
>
>#sectionIndex
>
>from a screen I get the following output in my browser:
>
>link: #mochalink ( Section [title='Intervention' index='1' 
>path='bingeeating.bequiz-feedback.be-conseq1.intervention'] Intervention )
>link: #mochalink ( Section [title='No Intervention' index='2' 
>path='bingeeating.bequiz-feedback.be-conseq1.nointervention'] No Intervention )
>
>It looks like Velocity is calling #sectionIndex fine but won't call 
>#mochaLink in turn, rather it simply expands #sectionlink and 
>#sectionlink.Title.  Is this expected behavior?  Is there a flag somewhere 
>that allows me to call macros from other macros?  Or is this sort of 
>functionality not supported, e.g. implement all behavior in sectionIndex 
>rather than calling mochaLink in turn?
>
>Thanks,
>Derek
>
>
>--
>To unsubscribe, 
>e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: 
><ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>