You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Hervé Guidetti <he...@idbsoft.ch> on 2001/03/27 15:06:16 UTC

Recurivity with Velocimacro

Hi all,

I need to create a tree with Velocity. So I need to write a Velocimacro
(displaying subTree) and calling it recursivly.

I tried to do it like that but it doesn't work.

#showsub($root)
#macro (showsub $sub_root)
 #foreach ($child in $sub_root.getAllChilds())
    <tr>
    <td valign=top>
     <img src="/img/sommaire/carre.gif" vspace=5></td>
    <td>
     $child.title
    </td></tr>
    #showsub($child)
 #end
#end


The first level of my tree is diplayed but the recurcivity doesn't work.
Any idea to do that ?


Hervé


Re: Recurivity with Velocimacro

Posted by Hervé Guidetti <he...@idbsoft.ch>.
Oooooooh yes,

Thank a lot
Hervé

----- Original Message -----
From: Geir Magnusson Jr. <ge...@optonline.net>
To: <ve...@jakarta.apache.org>
Sent: Tuesday, March 27, 2001 4:19 PM
Subject: Re: Recurivity with Velocimacro


> Hervé Guidetti wrote:
> >
> > Hi all,
> >
> > I need to create a tree with Velocity. So I need to write a Velocimacro
> > (displaying subTree) and calling it recursivly.
> >
> > I tried to do it like that but it doesn't work.
> >
> > #showsub($root)
> > #macro (showsub $sub_root)
> >  #foreach ($child in $sub_root.getAllChilds())
> >     <tr>
> >     <td valign=top>
> >      <img src="/img/sommaire/carre.gif" vspace=5></td>
> >     <td>
> >      $child.title
> >     </td></tr>
> >     #showsub($child)
> >  #end
> > #end
> >
> > The first level of my tree is diplayed but the recurcivity doesn't work.
> > Any idea to do that ?
>
> Put the call to showsub after the definition, see if that straightens it
> out.
>
> I know recursive VMs work just fine - in the whiteboard directory is an
> example of a treewalking VM that will walk and print out a JDOM tree.
>
> geir
> --
> Geir Magnusson Jr.                               geirm@optonline.net
> Developing for the web?  See http://jakarta.apache.org/velocity/
>


Re: Recurivity with Velocimacro

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Fedor Karpelevitch wrote:
> 
> On Tuesday 27 March 2001 06:19, you wrote:
> > Hervé Guidetti wrote:
> > > Hi all,
> > >
> > > I need to create a tree with Velocity. So I need to write a Velocimacro
> > > (displaying subTree) and calling it recursivly.
> > >
> > > I tried to do it like that but it doesn't work.
> > >
> > > #showsub($root)
> > > #macro (showsub $sub_root)
> > >  #foreach ($child in $sub_root.getAllChilds())
> > >     <tr>
> > >     <td valign=top>
> > >      <img src="/img/sommaire/carre.gif" vspace=5></td>
> > >     <td>
> > >      $child.title
> > >     </td></tr>
> > >     #showsub($child)
> > >  #end
> > > #end
> > >
> > > The first level of my tree is diplayed but the recurcivity doesn't work.
> > > Any idea to do that ?
> >
> > Put the call to showsub after the definition, see if that straightens it
> > out.
> 
> Is there any particular reason for this behaviour or this is just a bug?

I wouldn't call it a bug - it's not accidental or an oversight - but an
'enhancement' is coming after 1.0.

The problem is that the parser decides if something that looks like a
directive, i.e. #<foo>( [<arg>*] ) is a directive.  So the VMs have to
be 'known' at parse time.

The solution will be to resolve directives at runtime, not parsetime,
but then escaping and other issues will propogate outwards from the
parser.

Just something I wanted to wait until after 1.0 to change.

geir

-- 
Geir Magnusson Jr.                               geirm@optonline.net
Developing for the web?  See http://jakarta.apache.org/velocity/

Re: Recurivity with Velocimacro

Posted by Fedor Karpelevitch <fe...@home.com>.
On Tuesday 27 March 2001 06:19, you wrote:
> HervИ Guidetti wrote:
> > Hi all,
> >
> > I need to create a tree with Velocity. So I need to write a Velocimacro
> > (displaying subTree) and calling it recursivly.
> >
> > I tried to do it like that but it doesn't work.
> >
> > #showsub($root)
> > #macro (showsub $sub_root)
> >  #foreach ($child in $sub_root.getAllChilds())
> >     <tr>
> >     <td valign=top>
> >      <img src="/img/sommaire/carre.gif" vspace=5></td>
> >     <td>
> >      $child.title
> >     </td></tr>
> >     #showsub($child)
> >  #end
> > #end
> >
> > The first level of my tree is diplayed but the recurcivity doesn't work.
> > Any idea to do that ?
>
> Put the call to showsub after the definition, see if that straightens it
> out.

Is there any particular reason for this behaviour or this is just a bug?

fedor.

Re: Recurivity with Velocimacro

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Hervé Guidetti wrote:
> 
> Hi all,
> 
> I need to create a tree with Velocity. So I need to write a Velocimacro
> (displaying subTree) and calling it recursivly.
> 
> I tried to do it like that but it doesn't work.
> 
> #showsub($root)
> #macro (showsub $sub_root)
>  #foreach ($child in $sub_root.getAllChilds())
>     <tr>
>     <td valign=top>
>      <img src="/img/sommaire/carre.gif" vspace=5></td>
>     <td>
>      $child.title
>     </td></tr>
>     #showsub($child)
>  #end
> #end
> 
> The first level of my tree is diplayed but the recurcivity doesn't work.
> Any idea to do that ?

Put the call to showsub after the definition, see if that straightens it
out.

I know recursive VMs work just fine - in the whiteboard directory is an
example of a treewalking VM that will walk and print out a JDOM tree.

geir
-- 
Geir Magnusson Jr.                               geirm@optonline.net
Developing for the web?  See http://jakarta.apache.org/velocity/