You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Francois Armand <fa...@linagora.com> on 2007/05/03 10:27:50 UTC

[T5] Tree component and recursive component ?

Hello everybody,

I'm a beginner with Tapestry (and T5), and test it as a possible
framework for a futur application. 

I have tested T5 for 3 days and for now, I'm really impressed by it. But
I came to my first real problem (all others are related with the lack of
documentation, which is quite normal for an alpha release).

My application deals with LDAP directories, so I need to managed tree
structures all the time. But I saw that recursive component are not
allowed in T5, I think it is due to the "Principal 1 -- Static
Structure" of T5.

So, my question is : is there a way of implementing recursive
component ? If not, is there an existing component implementing a
non-recursive tree walk ? And if not, have you some advices about doing
such a component in T5 (say I know an algorithm for non-recursive tree
walk, what are the best practice in T5 ?)

Thanks you for your work, it's already quite impressive, and I hope it
will continue in this path. 

A last remark from a new tapestry(ies ?) user : it's a bit disturbing to
have 3 or 4 version of tapestry cohabiting, compatible or perhaps
not... 
It's a pain to find valid information, or just to find where to look.
Ok, Tapestry already has a (great) history, but T5 is something really
new, different and exiting. I think it would be great that T5 will be
clearly presented as that, with its own user list, community, wiki, etc,
and not as just a new version of an old framework (even if this old
framework was a breakthrough one, because t5 is a new breakthrough,
isn't it ?) 
But well, it's just my user point of view ;)

Francois


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


Re: [T5] Tree component and recursive component ?

Posted by Davor Hrg <hr...@gmail.com>.
I may be way off track, but adding recursive component support to print out
a menu or a tree
seems like a big overkill.

I have some hazy idea how this should be implemented:

in both cases we have a model with all the data we need,
a way to reuse single component (ActionLink) which would
generate events with an "id" extracted from current data element...
sth like cell renderers in swing.
ActionLink like this would always call same listener but with extra data
(id)



On 5/3/07, Howard Lewis Ship <hl...@gmail.com> wrote:
>
> I was just thinking about some of this on the way in.
>
>
> If you @Inject the ServiceResources into your Tree component, you can ask
> it
> to generate action links for you.  Handy!
>
> On 5/3/07, Francois Armand <fa...@linagora.com> wrote:
> >
> > Le jeudi 03 mai 2007 à 10:27 +0200, Francois Armand a écrit :
> > > Hello everybody,
> >
> > > So, my question is : is there a way of implementing recursive
> > > component ? If not, is there an existing component implementing a
> > > non-recursive tree walk ? And if not, have you some advices about
> doing
> > > such a component in T5 (say I know an algorithm for non-recursive tree
> > > walk, what are the best practice in T5 ?)
> > >
> >
> > Ok, I found that :
> > http://tapestry.apache.org/tapestry5/tapestry-core/guide/dom.html and I
> > can render my tree with ul/li tags thanks to MarkupWriter.
> >
> > But now, I want to add "actionlink" around each node content (the string
> > enclosed by <li> tags). How can I do that ? I think I can copy the code
> > from ActionLink, but perhaps there is a better method (well... Now that
> > I begin to play with MarkupWriter, I certainly have to use it for
> > everything...).
> >
> > Any advice would be appreciated :)
> >
> > Francois
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant
> Creator and PMC Chair, Apache Tapestry
> Creator, Apache HiveMind
>
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
>

Re: [T5] Tree component and recursive component ?

Posted by Francois Armand <fa...@linagora.com>.
Le jeudi 03 mai 2007 à 11:56 -0700, Howard Lewis Ship a écrit :
> I was just thinking about some of this on the way in.
> 
> 
> If you @Inject the ServiceResources into your Tree component, you can ask it
> to generate action links for you.  Handy!

Well, I succeeded in doing something... And Tapestry 5 is just amazing !

Now, I have a Tree component witch take a DefaultMutableTreeNode as
parameter and walk trough it in pre-order order, adding element at each
level swich, and write what I want for each node.

For exemple, if myTree has this structure :
8<---------------------
root
 |- node1
 |    |- node11
 |    `- node12
 |- node2
 `- node3
8<---------------------

and it is passed to my component in a template such as this :

8<---------------------
<t:tree source="mytree" currentnode="node" levelelement="ul">
  <li>
    <t:actionlink context="node.toString()">
      ${node.toString()}
    </t:actionlink>
  </li>
</t:tree>
8<---------------------

The rendered html will be :
8<---------------------
<ul>
  <li><a..>root</a><li>
  <ul>
    <li><a..>node1</a><li>
    <ul>
      <li><a..>node11</a><li>
      <li><a..>node12</a><li>
    </ul>
    <li><a..>node2</a><li>
    <li><a..>node3</a><li>
  </ul>
</ul>
8<---------------------

I'm a total beginner to T5 but that took me not a full day to understand
T5 base principles and code it... Wow. Really, Tapestry 5 is exiting.

Thanks for it, and I can't wait for the final version :)

Francois


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


Re: [T5] Tree component and recursive component ?

Posted by Howard Lewis Ship <hl...@gmail.com>.
I was just thinking about some of this on the way in.


If you @Inject the ServiceResources into your Tree component, you can ask it
to generate action links for you.  Handy!

On 5/3/07, Francois Armand <fa...@linagora.com> wrote:
>
> Le jeudi 03 mai 2007 à 10:27 +0200, Francois Armand a écrit :
> > Hello everybody,
>
> > So, my question is : is there a way of implementing recursive
> > component ? If not, is there an existing component implementing a
> > non-recursive tree walk ? And if not, have you some advices about doing
> > such a component in T5 (say I know an algorithm for non-recursive tree
> > walk, what are the best practice in T5 ?)
> >
>
> Ok, I found that :
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/dom.html and I
> can render my tree with ul/li tags thanks to MarkupWriter.
>
> But now, I want to add "actionlink" around each node content (the string
> enclosed by <li> tags). How can I do that ? I think I can copy the code
> from ActionLink, but perhaps there is a better method (well... Now that
> I begin to play with MarkupWriter, I certainly have to use it for
> everything...).
>
> Any advice would be appreciated :)
>
> Francois
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

Re: [T5] Tree component and recursive component ?

Posted by Francois Armand <fa...@linagora.com>.
Le jeudi 03 mai 2007 à 10:27 +0200, Francois Armand a écrit :
> Hello everybody,

> So, my question is : is there a way of implementing recursive
> component ? If not, is there an existing component implementing a
> non-recursive tree walk ? And if not, have you some advices about doing
> such a component in T5 (say I know an algorithm for non-recursive tree
> walk, what are the best practice in T5 ?)
> 

Ok, I found that :
http://tapestry.apache.org/tapestry5/tapestry-core/guide/dom.html and I
can render my tree with ul/li tags thanks to MarkupWriter.

But now, I want to add "actionlink" around each node content (the string
enclosed by <li> tags). How can I do that ? I think I can copy the code
from ActionLink, but perhaps there is a better method (well... Now that
I begin to play with MarkupWriter, I certainly have to use it for
everything...).

Any advice would be appreciated :)

Francois


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