Can a component include it selft

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Can a component include it selft

pepone.onrez
I have a TreeItem component and i want that if TreeItemModel hasChilds
render it in a Foreach component but allways i get a
java.lang.StackOverFlow exception

here is the component

<span jwcid="$content$">
        <div class="Label">
    <div jwcid="@Insert" value="ognl:model.getLabel(0)"/>
    </div>
    <div jwcid="@Conditional" condition="ognl:model.hasChilds()">
            <div class="Childs">
               <div jwcid="@Foreach" source="ognl:model.iterator" value="ognl:item">
                      <div jwcid="@TreeItemView" model="ognl:object"/>
              </div>
            </div>
    </div>
</span>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can a component include it selft

Mark Dillon
Recursive components are not supported in Tapestry 3.x.  Here's an
explanation and a potential solution:

http://www.behindthesite.com/blog/C1931765677/E923478269/index.html

Thanks,
Mark

On 5/23/05, pepone pepone <[hidden email]> wrote:

> I have a TreeItem component and i want that if TreeItemModel hasChilds
> render it in a Foreach component but allways i get a
> java.lang.StackOverFlow exception
>
> here is the component
>
> <span jwcid="$content$">
>         <div class="Label">
>                 <div jwcid="@Insert" value="ognl:model.getLabel(0)"/>
>     </div>
>     <div jwcid="@Conditional" condition="ognl:model.hasChilds()">
>             <div class="Childs">
>                <div jwcid="@Foreach" source="ognl:model.iterator" value="ognl:item">
>                            <div jwcid="@TreeItemView" model="ognl:object"/>
>                 </div>
>             </div>
>     </div>
> </span>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can a component include it selft

pepone.onrez
 can any body say me if recursive components are suported in 4.x

On 5/23/05, Mark Dillon <[hidden email]> wrote:

> Recursive components are not supported in Tapestry 3.x.  Here's an
> explanation and a potential solution:
>
> http://www.behindthesite.com/blog/C1931765677/E923478269/index.html
>
> Thanks,
> Mark
>
> On 5/23/05, pepone pepone <[hidden email]> wrote:
> > I have a TreeItem component and i want that if TreeItemModel hasChilds
> > render it in a Foreach component but allways i get a
> > java.lang.StackOverFlow exception
> >
> > here is the component
> >
> > <span jwcid="$content$">
> >         <div class="Label">
> >                 <div jwcid="@Insert" value="ognl:model.getLabel(0)"/>
> >     </div>
> >     <div jwcid="@Conditional" condition="ognl:model.hasChilds()">
> >             <div class="Childs">
> >                <div jwcid="@Foreach" source="ognl:model.iterator" value="ognl:item">
> >                            <div jwcid="@TreeItemView" model="ognl:object"/>
> >                 </div>
> >             </div>
> >     </div>
> > </span>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can a component include it selft

Viktor Szathmary
Most likely, you don't really need recursive components. Try unrolling
your hierarchical calls to an iterator, or use a component like the
tacos:Tree (http://tacos.sf.net/).

Even if the tree component doesn't work for you, tacos has a
TreeIterator that you can use to do hierarchical iteration (while
tracking depth).. See the source:

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

  viktor

On 5/23/05, pepone pepone <[hidden email]> wrote:

>  can any body say me if recursive components are suported in 4.x
>
> On 5/23/05, Mark Dillon <[hidden email]> wrote:
> > Recursive components are not supported in Tapestry 3.x.  Here's an
> > explanation and a potential solution:
> >
> > http://www.behindthesite.com/blog/C1931765677/E923478269/index.html
> >
> > Thanks,
> > Mark
> >
> > On 5/23/05, pepone pepone <[hidden email]> wrote:
> > > I have a TreeItem component and i want that if TreeItemModel hasChilds
> > > render it in a Foreach component but allways i get a
> > > java.lang.StackOverFlow exception
> > >
> > > here is the component
> > >
> > > <span jwcid="$content$">
> > >         <div class="Label">
> > >                 <div jwcid="@Insert" value="ognl:model.getLabel(0)"/>
> > >     </div>
> > >     <div jwcid="@Conditional" condition="ognl:model.hasChilds()">
> > >             <div class="Childs">
> > >                <div jwcid="@Foreach" source="ognl:model.iterator" value="ognl:item">
> > >                            <div jwcid="@TreeItemView" model="ognl:object"/>
> > >                 </div>
> > >             </div>
> > >     </div>
> > > </span>
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden email]
> > > For additional commands, e-mail: [hidden email]
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can a component include it selft

pepone.onrez
Hello

why tapestry don't suport recursivity? i know that recursivity is not
imprescindible but many times is the siplest solution.

I read the TreeIterator that Viktor coments but i think that this a
lot of extra code to write and like tapestry is about simplify thinks
i don't want to use this aproach

I read too the article in
http://www.behindthesite.com/blog/C1931765677/E923478269/index.html
but i can understand how to apply it to my problem.  any ideas?

is this behavior changuing in 4.x if yes i intersting in switch to 4.x now

Thanks to all tapestry comunity

On 5/24/05, Viktor Szathmary <[hidden email]> wrote:

> Most likely, you don't really need recursive components. Try unrolling
> your hierarchical calls to an iterator, or use a component like the
> tacos:Tree (http://tacos.sf.net/).
>
> Even if the tree component doesn't work for you, tacos has a
> TreeIterator that you can use to do hierarchical iteration (while
> tracking depth).. See the source:
>
> http://cvs.sourceforge.net/viewcvs.py/tacos/tacos/src/net/sf/tacos/tree/TreeIterator.java?rev=1.2&view=auto
>
>   viktor
>
> On 5/23/05, pepone pepone <[hidden email]> wrote:
> >  can any body say me if recursive components are suported in 4.x
> >
> > On 5/23/05, Mark Dillon <[hidden email]> wrote:
> > > Recursive components are not supported in Tapestry 3.x.  Here's an
> > > explanation and a potential solution:
> > >
> > > http://www.behindthesite.com/blog/C1931765677/E923478269/index.html
> > >
> > > Thanks,
> > > Mark
> > >
> > > On 5/23/05, pepone pepone <[hidden email]> wrote:
> > > > I have a TreeItem component and i want that if TreeItemModel hasChilds
> > > > render it in a Foreach component but allways i get a
> > > > java.lang.StackOverFlow exception
> > > >
> > > > here is the component
> > > >
> > > > <span jwcid="$content$">
> > > >         <div class="Label">
> > > >                 <div jwcid="@Insert" value="ognl:model.getLabel(0)"/>
> > > >     </div>
> > > >     <div jwcid="@Conditional" condition="ognl:model.hasChilds()">
> > > >             <div class="Childs">
> > > >                <div jwcid="@Foreach" source="ognl:model.iterator" value="ognl:item">
> > > >                            <div jwcid="@TreeItemView" model="ognl:object"/>
> > > >                 </div>
> > > >             </div>
> > > >     </div>
> > > > </span>
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [hidden email]
> > > > For additional commands, e-mail: [hidden email]
> > > >
> > > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Can a component include it selft

Mark Dillon
Notice this quote in the blog entry:

"found out that Tapestry, while loading the page and resolving
components, reads the declaration and template for every component not
already loaded. It resolves components in this way as it encounters
them in the page and component definitions and any recursive reference
to the component while it is being loaded causes the template and
specification to be loaded again, since the component is not yet
loaded! This results in an eventual Stack overflow or out of memory
exception as Tapestry stacks up loading of the same component over and
over again."

That is the root cause of your problem.  When Tapestry validates the
page template, it recursively resolves the components in the page.  If
it hits a recursive component, it will indefinitely resolve that
component, and eventually cause a stack overflow.  It can not evaluate
the conditionals in your component that would normally stop it from
recursing.  As far as I know, it still works this way in 4.x.

Mark

On 5/24/05, pepone pepone <[hidden email]> wrote:

> Hello
>
> why tapestry don't suport recursivity? i know that recursivity is not
> imprescindible but many times is the siplest solution.
>
> I read the TreeIterator that Viktor coments but i think that this a
> lot of extra code to write and like tapestry is about simplify thinks
> i don't want to use this aproach
>
> I read too the article in
> http://www.behindthesite.com/blog/C1931765677/E923478269/index.html
> but i can understand how to apply it to my problem.  any ideas?
>
> is this behavior changuing in 4.x if yes i intersting in switch to 4.x now
>
> Thanks to all tapestry comunity
>
> On 5/24/05, Viktor Szathmary <[hidden email]> wrote:
> > Most likely, you don't really need recursive components. Try unrolling
> > your hierarchical calls to an iterator, or use a component like the
> > tacos:Tree (http://tacos.sf.net/).
> >
> > Even if the tree component doesn't work for you, tacos has a
> > TreeIterator that you can use to do hierarchical iteration (while
> > tracking depth).. See the source:
> >
> > http://cvs.sourceforge.net/viewcvs.py/tacos/tacos/src/net/sf/tacos/tree/TreeIterator.java?rev=1.2&view=auto
> >
> >   viktor
> >
> > On 5/23/05, pepone pepone <[hidden email]> wrote:
> > >  can any body say me if recursive components are suported in 4.x
> > >
> > > On 5/23/05, Mark Dillon <[hidden email]> wrote:
> > > > Recursive components are not supported in Tapestry 3.x.  Here's an
> > > > explanation and a potential solution:
> > > >
> > > > http://www.behindthesite.com/blog/C1931765677/E923478269/index.html
> > > >
> > > > Thanks,
> > > > Mark
> > > >
> > > > On 5/23/05, pepone pepone <[hidden email]> wrote:
> > > > > I have a TreeItem component and i want that if TreeItemModel hasChilds
> > > > > render it in a Foreach component but allways i get a
> > > > > java.lang.StackOverFlow exception
> > > > >
> > > > > here is the component
> > > > >
> > > > > <span jwcid="$content$">
> > > > >         <div class="Label">
> > > > >                 <div jwcid="@Insert" value="ognl:model.getLabel(0)"/>
> > > > >     </div>
> > > > >     <div jwcid="@Conditional" condition="ognl:model.hasChilds()">
> > > > >             <div class="Childs">
> > > > >                <div jwcid="@Foreach" source="ognl:model.iterator" value="ognl:item">
> > > > >                            <div jwcid="@TreeItemView" model="ognl:object"/>
> > > > >                 </div>
> > > > >             </div>
> > > > >     </div>
> > > > > </span>
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: [hidden email]
> > > > > For additional commands, e-mail: [hidden email]
> > > > >
> > > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden email]
> > > For additional commands, e-mail: [hidden email]
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]