You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paul Cantrell <ca...@pobox.com> on 2005/08/10 23:31:00 UTC

Recursive rendering of tree model

Suppose I have some data like this:

     public interface TaxonomyTree
         {
         public String getAnimalName();
         public Set<TaxonomyTree> getChildren();
         }

...and suppose I want to render it in a page with a recursively  
nested structure, so that my HTML tag structure matches the tree  
structure of the data:

     <div>
         Birds
         <div> Hummingbird </div>
         <div> Warbler </div>
         <div> Raptor
             <div> Eagle </div>
             <div> Vulture </div>
         </div>
     </div>
     <div>
         Mammals
         <div> Platypus </div>
     ...etc...

Of course, *if* I know that the tree is n levels deep, I can render  
it with n nested @For components (though it's pretty ugly!). But if I  
don't know the depth of the tree, I need true recursion.

Is there a way to do this without writing a custom component for my  
specific data? Is anybody aware of a generic component that will do  
the job? I'm hoping for something like this:

     <span jwcid="animalTree@RecursiveFor" source="ognl:treeRootNodes">
         <div>
             <span jwcid="@Insert"  
value="ognl:components.animalTree.value.animalName" />
             <span jwcid="@RecursiveChildren" loop="animalTree"
                 value="ognl:components.animalTree.value.children" />
         </div>
     </span>

If nobody's aware of such a thing, I might try my hand at writing it.  
But I'd rather spare myself the effort if there's already a good  
solution out there....

Cheers,

Paul

_________________________________________________________________

"Les grandes personnes ne comprennent jamais rien toutes seules,
  et c'est fatigant, pour les enfants, de toujours et toujours
  leur donner des explications."     -- Antoine de Saint-Exupéry


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


Re: [Tacos-devel] Re: Recursive rendering of tree model

Posted by Jesse Kuhnert <jk...@gmail.com>.
Actually, the tacos4 module, which is tacos completely ported over to
tapestry 4 does use div tags to mark each node AND parent node in the
tree...

The tree also happens to support ajax requests right out of the box ;)
It should be officially released by the end of this week, along with a
lot of other enhancements to the library.

jesse
On 8/11/05, Norbert Sándor <de...@erinors.com> wrote:
> I have created a Tapestry4 compatible Tree component which uses real
> recursive rendering using Block and RenderBlock components. You should try
> using these components to implement template-based recursion.
> 
> BR,
> Norbi
> 
> ----- Original Message -----
> From: "Paul Cantrell" <ca...@pobox.com>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Thursday, August 11, 2005 12:50 AM
> Subject: Re: Recursive rendering of tree model
> 
> 
> Actually, on second inspection, that's not quite it.
> 
> The Tacos components uses CSS to indent the data:
> 
>      <div style="margin-left: 0px">
>          Parent
>      </div>
>      <div style="margin-left: 16px">
>          Child
>      </div>
> 
> But for my purposes (because of javascript manipulation of the DOM),
> it's very important that the tags actually *be nested* recursively:
> 
>      <div class="tree-node">
>          Parent
>          <div class="tree-node">
>              Child
>          </div>
>      </div>
> 
> So I guess it's not what I'm after. Slick component, though!
> 
> Cheers,
> 
> Paul
> 
> 
> On Aug 10, 2005, at 4:56 PM, Viktor Szathmary wrote:
> 
> > Check out the Tacos Tree component  (http://tacos.sf.net/). The source
> > has a TreeIterator that you can use independently to flatten out
> > hierarchical iterations so you can use a regular Foreach (while
> > tracking depth)...
> >
> > check the source for:
> >
> > http://cvs.sourceforge.net/viewcvs.py/tacos/tacos/src/net/sf/tacos/
> > tree/TreeIterator.java?rev=1.2&view=auto
> >
> >   viktor
> >
> >
> > On 8/10/05, Paul Cantrell <ca...@pobox.com> wrote:
> >
> >> Suppose I have some data like this:
> >>
> >>      public interface TaxonomyTree
> >>          {
> >>          public String getAnimalName();
> >>          public Set<TaxonomyTree> getChildren();
> >>          }
> >>
> >> ...and suppose I want to render it in a page with a recursively
> >> nested structure, so that my HTML tag structure matches the tree
> >> structure of the data:
> >>
> >>      <div>
> >>          Birds
> >>          <div> Hummingbird </div>
> >>          <div> Warbler </div>
> >>          <div> Raptor
> >>              <div> Eagle </div>
> >>              <div> Vulture </div>
> >>          </div>
> >>      </div>
> >>      <div>
> >>          Mammals
> >>          <div> Platypus </div>
> >>      ...etc...
> >>
> >> Of course, *if* I know that the tree is n levels deep, I can render
> >> it with n nested @For components (though it's pretty ugly!). But if I
> >> don't know the depth of the tree, I need true recursion.
> >>
> >> Is there a way to do this without writing a custom component for my
> >> specific data? Is anybody aware of a generic component that will do
> >> the job? I'm hoping for something like this:
> >>
> >>      <span jwcid="animalTree@RecursiveFor"  source="ognl:treeRootNodes">
> >>          <div>
> >>              <span jwcid="@Insert"
> >> value="ognl:components.animalTree.value.animalName" />
> >>              <span jwcid="@RecursiveChildren" loop="animalTree"
> >>                  value="ognl:components.animalTree.value.children" />
> >>          </div>
> >>      </span>
> >>
> >> If nobody's aware of such a thing, I might try my hand at writing it.
> >> But I'd rather spare myself the effort if there's already a good
> >> solution out there....
> >>
> >> Cheers,
> >>
> >> Paul
> >>
> >> _________________________________________________________________
> >>
> >> "Les grandes personnes ne comprennent jamais rien toutes seules,
> >>   et c'est fatigant, pour les enfants, de toujours et toujours
> >>   leur donner des explications."     -- Antoine de Saint-Exupéry
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: tapestry-user- help@jakarta.apache.org
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> >
> 
> _________________________________________________________________
> 
> "The pursuit of truth and beauty is a sphere of activity in which
> we are permitted to remain children all our lives."
> -- Albert Einstein
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> 
> 
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is Sponsored by the Better Software Conference & EXPO
> September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
> Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
> Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
> _______________________________________________
> Tacos-devel mailing list
> Tacos-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tacos-devel
>

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


Re: Recursive rendering of tree model

Posted by Norbert Sándor <de...@erinors.com>.
I have created a Tapestry4 compatible Tree component which uses real 
recursive rendering using Block and RenderBlock components. You should try 
using these components to implement template-based recursion.

BR,
Norbi

----- Original Message ----- 
From: "Paul Cantrell" <ca...@pobox.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, August 11, 2005 12:50 AM
Subject: Re: Recursive rendering of tree model


Actually, on second inspection, that's not quite it.

The Tacos components uses CSS to indent the data:

     <div style="margin-left: 0px">
         Parent
     </div>
     <div style="margin-left: 16px">
         Child
     </div>

But for my purposes (because of javascript manipulation of the DOM),
it's very important that the tags actually *be nested* recursively:

     <div class="tree-node">
         Parent
         <div class="tree-node">
             Child
         </div>
     </div>

So I guess it's not what I'm after. Slick component, though!

Cheers,

Paul


On Aug 10, 2005, at 4:56 PM, Viktor Szathmary wrote:

> Check out the Tacos Tree component  (http://tacos.sf.net/). The source
> has a TreeIterator that you can use independently to flatten out
> hierarchical iterations so you can use a regular Foreach (while
> tracking depth)...
>
> check the source for:
>
> http://cvs.sourceforge.net/viewcvs.py/tacos/tacos/src/net/sf/tacos/ 
> tree/TreeIterator.java?rev=1.2&view=auto
>
>   viktor
>
>
> On 8/10/05, Paul Cantrell <ca...@pobox.com> wrote:
>
>> Suppose I have some data like this:
>>
>>      public interface TaxonomyTree
>>          {
>>          public String getAnimalName();
>>          public Set<TaxonomyTree> getChildren();
>>          }
>>
>> ...and suppose I want to render it in a page with a recursively
>> nested structure, so that my HTML tag structure matches the tree
>> structure of the data:
>>
>>      <div>
>>          Birds
>>          <div> Hummingbird </div>
>>          <div> Warbler </div>
>>          <div> Raptor
>>              <div> Eagle </div>
>>              <div> Vulture </div>
>>          </div>
>>      </div>
>>      <div>
>>          Mammals
>>          <div> Platypus </div>
>>      ...etc...
>>
>> Of course, *if* I know that the tree is n levels deep, I can render
>> it with n nested @For components (though it's pretty ugly!). But if I
>> don't know the depth of the tree, I need true recursion.
>>
>> Is there a way to do this without writing a custom component for my
>> specific data? Is anybody aware of a generic component that will do
>> the job? I'm hoping for something like this:
>>
>>      <span jwcid="animalTree@RecursiveFor"  source="ognl:treeRootNodes">
>>          <div>
>>              <span jwcid="@Insert"
>> value="ognl:components.animalTree.value.animalName" />
>>              <span jwcid="@RecursiveChildren" loop="animalTree"
>>                  value="ognl:components.animalTree.value.children" />
>>          </div>
>>      </span>
>>
>> If nobody's aware of such a thing, I might try my hand at writing it.
>> But I'd rather spare myself the effort if there's already a good
>> solution out there....
>>
>> Cheers,
>>
>> Paul
>>
>> _________________________________________________________________
>>
>> "Les grandes personnes ne comprennent jamais rien toutes seules,
>>   et c'est fatigant, pour les enfants, de toujours et toujours
>>   leur donner des explications."     -- Antoine de Saint-Exupéry
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user- help@jakarta.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>

_________________________________________________________________

"The pursuit of truth and beauty is a sphere of activity in which
we are permitted to remain children all our lives."
-- Albert Einstein



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






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


Re: Recursive rendering of tree model

Posted by Paul Cantrell <ca...@pobox.com>.
Actually, on second inspection, that's not quite it.

The Tacos components uses CSS to indent the data:

     <div style="margin-left: 0px">
         Parent
     </div>
     <div style="margin-left: 16px">
         Child
     </div>

But for my purposes (because of javascript manipulation of the DOM),  
it's very important that the tags actually *be nested* recursively:

     <div class="tree-node">
         Parent
         <div class="tree-node">
             Child
         </div>
     </div>

So I guess it's not what I'm after. Slick component, though!

Cheers,

Paul


On Aug 10, 2005, at 4:56 PM, Viktor Szathmary wrote:

> Check out the Tacos Tree component  (http://tacos.sf.net/). The source
> has a TreeIterator that you can use independently to flatten out
> hierarchical iterations so you can use a regular Foreach (while
> tracking depth)...
>
> check the source for:
>
> http://cvs.sourceforge.net/viewcvs.py/tacos/tacos/src/net/sf/tacos/ 
> tree/TreeIterator.java?rev=1.2&view=auto
>
>   viktor
>
>
> On 8/10/05, Paul Cantrell <ca...@pobox.com> wrote:
>
>> Suppose I have some data like this:
>>
>>      public interface TaxonomyTree
>>          {
>>          public String getAnimalName();
>>          public Set<TaxonomyTree> getChildren();
>>          }
>>
>> ...and suppose I want to render it in a page with a recursively
>> nested structure, so that my HTML tag structure matches the tree
>> structure of the data:
>>
>>      <div>
>>          Birds
>>          <div> Hummingbird </div>
>>          <div> Warbler </div>
>>          <div> Raptor
>>              <div> Eagle </div>
>>              <div> Vulture </div>
>>          </div>
>>      </div>
>>      <div>
>>          Mammals
>>          <div> Platypus </div>
>>      ...etc...
>>
>> Of course, *if* I know that the tree is n levels deep, I can render
>> it with n nested @For components (though it's pretty ugly!). But if I
>> don't know the depth of the tree, I need true recursion.
>>
>> Is there a way to do this without writing a custom component for my
>> specific data? Is anybody aware of a generic component that will do
>> the job? I'm hoping for something like this:
>>
>>      <span jwcid="animalTree@RecursiveFor"  
>> source="ognl:treeRootNodes">
>>          <div>
>>              <span jwcid="@Insert"
>> value="ognl:components.animalTree.value.animalName" />
>>              <span jwcid="@RecursiveChildren" loop="animalTree"
>>                  value="ognl:components.animalTree.value.children" />
>>          </div>
>>      </span>
>>
>> If nobody's aware of such a thing, I might try my hand at writing it.
>> But I'd rather spare myself the effort if there's already a good
>> solution out there....
>>
>> Cheers,
>>
>> Paul
>>
>> _________________________________________________________________
>>
>> "Les grandes personnes ne comprennent jamais rien toutes seules,
>>   et c'est fatigant, pour les enfants, de toujours et toujours
>>   leur donner des explications."     -- Antoine de Saint-Exupéry
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user- 
>> help@jakarta.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>

_________________________________________________________________

"The pursuit of truth and beauty is a sphere of activity in which
we are permitted to remain children all our lives."
-- Albert Einstein



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


Re: Recursive rendering of tree model

Posted by Paul Cantrell <ca...@pobox.com>.
Ah, that's a starting point. I'm actually looking for something that  
does a little *less* -- doesn't render the collapse/expand button,  
just the nested components -- but that should be easy to strip out.

Nice set of components. Thanks!

Cheers,

Paul

On Aug 10, 2005, at 4:56 PM, Viktor Szathmary wrote:

> Check out the Tacos Tree component  (http://tacos.sf.net/). The source
> has a TreeIterator that you can use independently to flatten out
> hierarchical iterations so you can use a regular Foreach (while
> tracking depth)...
>
> check the source for:
>
> http://cvs.sourceforge.net/viewcvs.py/tacos/tacos/src/net/sf/tacos/ 
> tree/TreeIterator.java?rev=1.2&view=auto
>
>   viktor
>
>
> On 8/10/05, Paul Cantrell <ca...@pobox.com> wrote:
>
>> Suppose I have some data like this:
>>
>>      public interface TaxonomyTree
>>          {
>>          public String getAnimalName();
>>          public Set<TaxonomyTree> getChildren();
>>          }
>>
>> ...and suppose I want to render it in a page with a recursively
>> nested structure, so that my HTML tag structure matches the tree
>> structure of the data:
>>
>>      <div>
>>          Birds
>>          <div> Hummingbird </div>
>>          <div> Warbler </div>
>>          <div> Raptor
>>              <div> Eagle </div>
>>              <div> Vulture </div>
>>          </div>
>>      </div>
>>      <div>
>>          Mammals
>>          <div> Platypus </div>
>>      ...etc...
>>
>> Of course, *if* I know that the tree is n levels deep, I can render
>> it with n nested @For components (though it's pretty ugly!). But if I
>> don't know the depth of the tree, I need true recursion.
>>
>> Is there a way to do this without writing a custom component for my
>> specific data? Is anybody aware of a generic component that will do
>> the job? I'm hoping for something like this:
>>
>>      <span jwcid="animalTree@RecursiveFor"  
>> source="ognl:treeRootNodes">
>>          <div>
>>              <span jwcid="@Insert"
>> value="ognl:components.animalTree.value.animalName" />
>>              <span jwcid="@RecursiveChildren" loop="animalTree"
>>                  value="ognl:components.animalTree.value.children" />
>>          </div>
>>      </span>
>>
>> If nobody's aware of such a thing, I might try my hand at writing it.
>> But I'd rather spare myself the effort if there's already a good
>> solution out there....
>>
>> Cheers,
>>
>> Paul
>>
>> _________________________________________________________________
>>
>> "Les grandes personnes ne comprennent jamais rien toutes seules,
>>   et c'est fatigant, pour les enfants, de toujours et toujours
>>   leur donner des explications."     -- Antoine de Saint-Exupéry
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user- 
>> help@jakarta.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>

_________________________________________________________________

"Nationalism is an infantile disease. It is the measles of mankind."
-- Albert Einstein


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


Re: Recursive rendering of tree model

Posted by Viktor Szathmary <ph...@gmail.com>.
Check out the Tacos Tree component  (http://tacos.sf.net/). The source
has a TreeIterator that you can use independently to flatten out
hierarchical iterations so you can use a regular Foreach (while
tracking depth)...

check the source for: 

http://cvs.sourceforge.net/viewcvs.py/tacos/tacos/src/net/sf/tacos/tree/TreeIterator.java?rev=1.2&view=auto

  viktor


On 8/10/05, Paul Cantrell <ca...@pobox.com> wrote:
> Suppose I have some data like this:
> 
>      public interface TaxonomyTree
>          {
>          public String getAnimalName();
>          public Set<TaxonomyTree> getChildren();
>          }
> 
> ...and suppose I want to render it in a page with a recursively
> nested structure, so that my HTML tag structure matches the tree
> structure of the data:
> 
>      <div>
>          Birds
>          <div> Hummingbird </div>
>          <div> Warbler </div>
>          <div> Raptor
>              <div> Eagle </div>
>              <div> Vulture </div>
>          </div>
>      </div>
>      <div>
>          Mammals
>          <div> Platypus </div>
>      ...etc...
> 
> Of course, *if* I know that the tree is n levels deep, I can render
> it with n nested @For components (though it's pretty ugly!). But if I
> don't know the depth of the tree, I need true recursion.
> 
> Is there a way to do this without writing a custom component for my
> specific data? Is anybody aware of a generic component that will do
> the job? I'm hoping for something like this:
> 
>      <span jwcid="animalTree@RecursiveFor" source="ognl:treeRootNodes">
>          <div>
>              <span jwcid="@Insert"
> value="ognl:components.animalTree.value.animalName" />
>              <span jwcid="@RecursiveChildren" loop="animalTree"
>                  value="ognl:components.animalTree.value.children" />
>          </div>
>      </span>
> 
> If nobody's aware of such a thing, I might try my hand at writing it.
> But I'd rather spare myself the effort if there's already a good
> solution out there....
> 
> Cheers,
> 
> Paul
> 
> _________________________________________________________________
> 
> "Les grandes personnes ne comprennent jamais rien toutes seules,
>   et c'est fatigant, pour les enfants, de toujours et toujours
>   leur donner des explications."     -- Antoine de Saint-Exupéry
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

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


Re: Recursive rendering of tree model

Posted by Paul Cantrell <ca...@pobox.com>.
It seems that it wouldn't be too difficult to write an  
AbstractComponent that manually writes everything to the writer.

I'm hoping for something that *is* template-based -- that I can reuse  
in many different recursive situations. It's at least useful to know  
that you gave up on this....

Paul

On Aug 10, 2005, at 4:34 PM, Danny Mandel wrote:

> Hi Paul.  For the tree of life we have similar requirements and I  
> found it was easiest to accomplish what you are describing using an  
> AbstractComponent (programmatic, not template-based) subclass, as  
> it just got too messy when trying to accomplish the same thing with  
> templates.
>
> Hope that helps,
> Danny
>
> Paul Cantrell wrote:
>
>
>> Suppose I have some data like this:
>>
>>     public interface TaxonomyTree
>>         {
>>         public String getAnimalName();
>>         public Set<TaxonomyTree> getChildren();
>>         }
>>
>> ...and suppose I want to render it in a page with a recursively   
>> nested structure, so that my HTML tag structure matches the tree   
>> structure of the data:
>>
>>     <div>
>>         Birds
>>         <div> Hummingbird </div>
>>         <div> Warbler </div>
>>         <div> Raptor
>>             <div> Eagle </div>
>>             <div> Vulture </div>
>>         </div>
>>     </div>
>>     <div>
>>         Mammals
>>         <div> Platypus </div>
>>     ...etc...
>>
>> Of course, *if* I know that the tree is n levels deep, I can  
>> render  it with n nested @For components (though it's pretty  
>> ugly!). But if I  don't know the depth of the tree, I need true  
>> recursion.
>>
>> Is there a way to do this without writing a custom component for  
>> my  specific data? Is anybody aware of a generic component that  
>> will do  the job? I'm hoping for something like this:
>>
>>     <span jwcid="animalTree@RecursiveFor"  
>> source="ognl:treeRootNodes">
>>         <div>
>>             <span jwcid="@Insert"   
>> value="ognl:components.animalTree.value.animalName" />
>>             <span jwcid="@RecursiveChildren" loop="animalTree"
>>                 value="ognl:components.animalTree.value.children" />
>>         </div>
>>     </span>
>>
>> If nobody's aware of such a thing, I might try my hand at writing  
>> it.  But I'd rather spare myself the effort if there's already a  
>> good  solution out there....
>>
>> Cheers,
>>
>> Paul
>>
>> _________________________________________________________________
>>
>> "Les grandes personnes ne comprennent jamais rien toutes seules,
>>  et c'est fatigant, pour les enfants, de toujours et toujours
>>  leur donner des explications."     -- Antoine de Saint-Exupéry
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user- 
>> help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>

_________________________________________________________________

"Nationalism is an infantile disease. It is the measles of mankind."
-- Albert Einstein


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


Re: Recursive rendering of tree model

Posted by Danny Mandel <dm...@tolweb.org>.
Hi Paul.  For the tree of life we have similar requirements and I found 
it was easiest to accomplish what you are describing using an 
AbstractComponent (programmatic, not template-based) subclass, as it 
just got too messy when trying to accomplish the same thing with templates.

Hope that helps,
Danny

Paul Cantrell wrote:

> Suppose I have some data like this:
>
>     public interface TaxonomyTree
>         {
>         public String getAnimalName();
>         public Set<TaxonomyTree> getChildren();
>         }
>
> ...and suppose I want to render it in a page with a recursively  
> nested structure, so that my HTML tag structure matches the tree  
> structure of the data:
>
>     <div>
>         Birds
>         <div> Hummingbird </div>
>         <div> Warbler </div>
>         <div> Raptor
>             <div> Eagle </div>
>             <div> Vulture </div>
>         </div>
>     </div>
>     <div>
>         Mammals
>         <div> Platypus </div>
>     ...etc...
>
> Of course, *if* I know that the tree is n levels deep, I can render  
> it with n nested @For components (though it's pretty ugly!). But if I  
> don't know the depth of the tree, I need true recursion.
>
> Is there a way to do this without writing a custom component for my  
> specific data? Is anybody aware of a generic component that will do  
> the job? I'm hoping for something like this:
>
>     <span jwcid="animalTree@RecursiveFor" source="ognl:treeRootNodes">
>         <div>
>             <span jwcid="@Insert"  
> value="ognl:components.animalTree.value.animalName" />
>             <span jwcid="@RecursiveChildren" loop="animalTree"
>                 value="ognl:components.animalTree.value.children" />
>         </div>
>     </span>
>
> If nobody's aware of such a thing, I might try my hand at writing it.  
> But I'd rather spare myself the effort if there's already a good  
> solution out there....
>
> Cheers,
>
> Paul
>
> _________________________________________________________________
>
> "Les grandes personnes ne comprennent jamais rien toutes seules,
>  et c'est fatigant, pour les enfants, de toujours et toujours
>  leur donner des explications."     -- Antoine de Saint-Exupéry
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


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