You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nicolas Barrera <nb...@gmail.com> on 2012/05/23 15:09:41 UTC

T5.3 's Tree in a Loop

Hi,

I got the need to show a dynamic number of tree components in a page, I
thought about using a loop around a tree component but I 've bumped with
the problem that I 'll need to
set the Tree's model property with something variable.

I 've already tried this:

    <t:loop t:source="loopData" t:value="loopValue">

        <t:tree t:model="getTreeModel(loopValue)"

and I could render two trees but when I tried to expand one branch of a
tree it executed again the getTreeModel but with a null parameter so
it finally didn't work as I expected.

can anyone give me a hint on how could this be accomplished?

cheers and thanks...

Nicolás.-

Re: T5.3 's Tree in a Loop

Posted by Lance Java <la...@googlemail.com>.
This sounds like a generic problem which might have a generic solution. If
the Loop component push()ed the current element onto the environment,
EventLinks could peek() for the value when rendering an ajax link. When an
ajax even fires, tapestry could populate the current loop value in the
component stack so that hopefully any methods referencing the loop value
work as expected.

It sounds plausible to me but I have no idea if it would work.

Re: T5.3 's Tree in a Loop

Posted by Nicolas Barrera <nb...@gmail.com>.
Ok, thanks both for your help...

I 'll see if I can modify Tree's eventlink behaviour to have the needed
information.

I 'll update here if I reach some progress

cheers and thanks

Nicolás.-


On Wed, May 23, 2012 at 12:59 PM, Arno Haase <
arno.haase@haase-consulting.com> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Sorry, my mistake - I replied without really thinking...
>
> I was thinking about a similar phenomenon when a loop contains links
> that refer to the loop variable, e.g. as their context. Then you need
> to use 'deferred="true"' with the links.
>
> As Lance wrote, there may not be analogous support for trees in a loop.
>
>
>
>
> Am 23.05.2012 16:44, schrieb Nicolas Barrera:
> > Arno, sorry can you send me the link of the javadoc you 're looking
> > at? 'cause I couldn't find nothing about deffered in
> >
> http://tapestry.apache.org/5.3.3/apidocs/org/apache/tapestry5/corelib/components/Loop.html
> >
> >  Lance, I 'm thinking about what you said and the loop and form
> > relationship,
> >
> > I don't know if this is the real problem but what I could see is
> > that as I got t:model="getTreeModel(loopValue)" the first time
> > (when the tree is first rendered) all values are ok and the tree
> > renders.
> >
> > after that when i try to expand a branch a method on the Tree
> > component (I think that it is the onExpandChildren method)  is
> > called that method tries to retrieve the model of the tree
> > component by calling this.model and it's like it tries to execute
> > getTreeModel(loopValue),
> >
> > can't this value be cached in the component? is it that conduits
> > are never cached?
> >
> > sorry but I think I 'm not understanding the basic of conduits.
> >
> > cheers
> >
> > Nicolás.-
> >
> >
> > On Wed, May 23, 2012 at 10:55 AM, Lance Java
> > <la...@googlemail.com>wrote:
> >
> >> I'm not 100% sure but I think you might have encountered a tricky
> >> issue. The Loop component uses the "encoder" property to
> >> integrate with the Form component so that the list is serialized
> >> to a hidden form element and then deserialized when the form is
> >> posted. I don't think that the same kind of integration exists
> >> between Loop and Tree.
> >>
> >> Perhaps someone has a workaround for you but I can't think of one
> >> off the top of my head.
> >>
> >> -- View this message in context:
> >>
> http://tapestry.1045711.n5.nabble.com/T5-3-s-Tree-in-a-Loop-tp5713347p5713351.html
> >>
> >>
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >>
> >>
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk+9CVkACgkQbmZsMyUPuXT1SgCgs8xMORc68C5ZxhEPTSlqID7M
> hOsAnAtse28SA7Lsg/JgIMrLtLRKgreg
> =4lmt
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5.3 's Tree in a Loop

Posted by Arno Haase <ar...@haase-consulting.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sorry, my mistake - I replied without really thinking...

I was thinking about a similar phenomenon when a loop contains links
that refer to the loop variable, e.g. as their context. Then you need
to use 'deferred="true"' with the links.

As Lance wrote, there may not be analogous support for trees in a loop.




Am 23.05.2012 16:44, schrieb Nicolas Barrera:
> Arno, sorry can you send me the link of the javadoc you 're looking
> at? 'cause I couldn't find nothing about deffered in 
> http://tapestry.apache.org/5.3.3/apidocs/org/apache/tapestry5/corelib/components/Loop.html
>
>  Lance, I 'm thinking about what you said and the loop and form
> relationship,
> 
> I don't know if this is the real problem but what I could see is
> that as I got t:model="getTreeModel(loopValue)" the first time
> (when the tree is first rendered) all values are ok and the tree
> renders.
> 
> after that when i try to expand a branch a method on the Tree
> component (I think that it is the onExpandChildren method)  is
> called that method tries to retrieve the model of the tree
> component by calling this.model and it's like it tries to execute
> getTreeModel(loopValue),
> 
> can't this value be cached in the component? is it that conduits
> are never cached?
> 
> sorry but I think I 'm not understanding the basic of conduits.
> 
> cheers
> 
> Nicolás.-
> 
> 
> On Wed, May 23, 2012 at 10:55 AM, Lance Java
> <la...@googlemail.com>wrote:
> 
>> I'm not 100% sure but I think you might have encountered a tricky
>> issue. The Loop component uses the "encoder" property to
>> integrate with the Form component so that the list is serialized
>> to a hidden form element and then deserialized when the form is
>> posted. I don't think that the same kind of integration exists
>> between Loop and Tree.
>> 
>> Perhaps someone has a workaround for you but I can't think of one
>> off the top of my head.
>> 
>> -- View this message in context: 
>> http://tapestry.1045711.n5.nabble.com/T5-3-s-Tree-in-a-Loop-tp5713347p5713351.html
>>
>> 
Sent from the Tapestry - User mailing list archive at Nabble.com.
>> 
>> ---------------------------------------------------------------------
>>
>> 
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+9CVkACgkQbmZsMyUPuXT1SgCgs8xMORc68C5ZxhEPTSlqID7M
hOsAnAtse28SA7Lsg/JgIMrLtLRKgreg
=4lmt
-----END PGP SIGNATURE-----

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


Re: T5.3 's Tree in a Loop

Posted by Lance Java <la...@googlemail.com>.
Think about it this way, once your page has rendered the trees, this list is
gone unless it stored it in the html or in the session (bad). 

Take a look at the event link that tapestry generates to expand a tree node,
I'm betting that it does not contain enough information to determine the
loop value.

I think the solution involves the tree component generating an eventlink
such that it has enough information to determine it's model in the ajax
event.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-3-s-Tree-in-a-Loop-tp5713347p5713358.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: T5.3 's Tree in a Loop

Posted by Nicolas Barrera <nb...@gmail.com>.
Arno, sorry can you send me the link of the javadoc you 're looking at?
'cause I couldn't find nothing about deffered in
http://tapestry.apache.org/5.3.3/apidocs/org/apache/tapestry5/corelib/components/Loop.html

Lance, I 'm thinking about what you said and the loop and form relationship,

I don't know if this is the real problem but what I could see is that as I
got t:model="getTreeModel(loopValue)"
the first time (when the tree is first rendered) all values are ok and the
tree renders.

after that when i try to expand a branch a method on the Tree component (I
think that it is the onExpandChildren method)  is called that method tries
to retrieve the model of the tree component by calling
this.model and it's like it tries to execute getTreeModel(loopValue),

can't this value be cached in the component?
is it that conduits are never cached?

sorry but I think I 'm not understanding the basic of conduits.

cheers

Nicolás.-


On Wed, May 23, 2012 at 10:55 AM, Lance Java <la...@googlemail.com>wrote:

> I'm not 100% sure but I think you might have encountered a tricky issue.
> The
> Loop component uses the "encoder" property to integrate with the Form
> component so that the list is serialized to a hidden form element and then
> deserialized when the form is posted. I don't think that the same kind of
> integration exists between Loop and Tree.
>
> Perhaps someone has a workaround for you but I can't think of one off the
> top of my head.
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/T5-3-s-Tree-in-a-Loop-tp5713347p5713351.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5.3 's Tree in a Loop

Posted by Lance Java <la...@googlemail.com>.
I'm not 100% sure but I think you might have encountered a tricky issue. The
Loop component uses the "encoder" property to integrate with the Form
component so that the list is serialized to a hidden form element and then
deserialized when the form is posted. I don't think that the same kind of
integration exists between Loop and Tree.

Perhaps someone has a workaround for you but I can't think of one off the
top of my head.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-3-s-Tree-in-a-Loop-tp5713347p5713351.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: T5.3 's Tree in a Loop

Posted by Arno Haase <ar...@haase-consulting.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

try adding

deferred="false"

to the loop - see javadoc for explanations.


Am 23.05.2012 15:09, schrieb Nicolas Barrera:
> Hi,
> 
> I got the need to show a dynamic number of tree components in a
> page, I thought about using a loop around a tree component but I
> 've bumped with the problem that I 'll need to set the Tree's model
> property with something variable.
> 
> I 've already tried this:
> 
> <t:loop t:source="loopData" t:value="loopValue">
> 
> <t:tree t:model="getTreeModel(loopValue)"
> 
> and I could render two trees but when I tried to expand one branch
> of a tree it executed again the getTreeModel but with a null
> parameter so it finally didn't work as I expected.
> 
> can anyone give me a hint on how could this be accomplished?
> 
> cheers and thanks...
> 
> Nicolás.-
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk+86aAACgkQbmZsMyUPuXSoTgCg2dKyQja0xmj6MzBqXg6wfcUs
qpgAn3SWfoSIlVS1y0W0HPlz02SCfvGM
=GG3g
-----END PGP SIGNATURE-----

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