You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by yamsterdamer <ma...@tapestryforums.com> on 2006/01/17 10:13:42 UTC
re-instantiate components in a loop
> Hi.
> I'm using T4, and in some of my pages I create components within a loop.
> From what I have seen, seems like tapestry re-initializes the instance of the component with different parameters in each iteration, instead of instantiating a new component.
> For example, looking at the component hierarchy on the run, I see that tapestry components like If, Insert etc are instantiated more than one time, getting ids like If_0, If_1. How can I do the same with mine? (again, within a loop!)
> The ultimate goal is to allow each component to keep its own parameters, in order to use them later on re-render.
> However, even a way of getting an indication to which component (index? Id? Location?) is being re-rendered will do for now
> Thanks a lot,
> Yael.
Sorry for the double posting, I really need help on this...
-------------------- m2f --------------------
Sent from www.TapestryForums.com
Read this topic online here: <<topic_link>>
http://www.tapestryforums.com/viewtopic.php?p=13299#13299
-------------------- m2f --------------------
Re: re-instantiate components in a loop
Posted by Ron Piterman <rp...@gmx.net>.
you could change direct link's stateful parameter to true. I would
expect it will do the same?
Stijn Christiaens wrote:
> Maybe this is also not such a good idea, as ActionLink is depecrated and
> will be removed in 4.1.
> I've seen someone ask what the replacement was, but it never saw the
> answer. The documentation also does not say what you should replace it
> by.
>
> Ciao,
>
> Stijn
>
> On Tue, 2006-01-17 at 16:37 +0100, Ron Piterman wrote:
>
>>Hallo Yael,
>>
>>I never really used contrib:table but I guess, this happens because the
>>table uses the wrong link type for sorting, I guess the DirectLink, but
>>am not really sure about that -
>>instead you should "convince" the table to use ActionLink -
>>this will make the page rerender (before rendering the page for output,
>>also called rewinding) and the listener will be called during the
>>iteration of the For, so each component will have its binding set.
>>
>>I would guess that the contrib:Table should be able to do that given the
>>right parameters.
>>
>>Anyway, this is a case for Mind Bridge to tell...
>>Try posting again with something like: "changing contrib table sort
>>links ActionLink instead of DirectLink" in the subject...
>>
>>Hope that helps,
>>Cheers,
>>Ron
>>
>>
>>
>>
>>yamsterdamer wrote:
>>
>>>Hi Ron
>>>I think you pretty much got it right.
>>>
>>>For
>>>|___Component
>>> |___Contrib Table
>>>
>>>Step 1: the loop is rendering itself
>>>2: in the first iteration a component with current parameters and an id, let's say “myComp” is being created, and renders itself
>>>3: in the second iteration the same component with the id “myComp” is given different parameters, and renders itself again
>>>4: and so on in the next iterations
>>>5: the loop ends. The index/ value are deleted, and so is “myComp”
>>>6: the page is displayed
>>>7: the user presses sort link on one column of one of the tables.
>>>8: the sort link requests for the component “myComp” (why? In order to retrieve table parameters from it, I suppose)
>>>9: the returned “myComp” is not initialized.
>>>10: the table tries to get its parameters from “myComp”
>>>11: null pointer exception
>>>
>>>Very simple. Seems like a trivial thing to do, doesn’t it?
>>>
>>>
>>>-------------------- m2f --------------------
>>>
>>>Sent from www.TapestryForums.com
>>>
>>>Read this topic online here: <<topic_link>>
>>>
>>>http://www.tapestryforums.com/viewtopic.php?p=13315#13315
>>>
>>>-------------------- m2f --------------------
>>>
>>>
>>>
>>
>>
>>---------------------------------------------------------------------
>>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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: re-instantiate components in a loop
Posted by Stijn Christiaens <st...@vub.ac.be>.
Maybe this is also not such a good idea, as ActionLink is depecrated and
will be removed in 4.1.
I've seen someone ask what the replacement was, but it never saw the
answer. The documentation also does not say what you should replace it
by.
Ciao,
Stijn
On Tue, 2006-01-17 at 16:37 +0100, Ron Piterman wrote:
> Hallo Yael,
>
> I never really used contrib:table but I guess, this happens because the
> table uses the wrong link type for sorting, I guess the DirectLink, but
> am not really sure about that -
> instead you should "convince" the table to use ActionLink -
> this will make the page rerender (before rendering the page for output,
> also called rewinding) and the listener will be called during the
> iteration of the For, so each component will have its binding set.
>
> I would guess that the contrib:Table should be able to do that given the
> right parameters.
>
> Anyway, this is a case for Mind Bridge to tell...
> Try posting again with something like: "changing contrib table sort
> links ActionLink instead of DirectLink" in the subject...
>
> Hope that helps,
> Cheers,
> Ron
>
>
>
>
> yamsterdamer wrote:
> > Hi Ron
> > I think you pretty much got it right.
> >
> > For
> > |___Component
> > |___Contrib Table
> >
> > Step 1: the loop is rendering itself
> > 2: in the first iteration a component with current parameters and an id, let's say “myComp” is being created, and renders itself
> > 3: in the second iteration the same component with the id “myComp” is given different parameters, and renders itself again
> > 4: and so on in the next iterations
> > 5: the loop ends. The index/ value are deleted, and so is “myComp”
> > 6: the page is displayed
> > 7: the user presses sort link on one column of one of the tables.
> > 8: the sort link requests for the component “myComp” (why? In order to retrieve table parameters from it, I suppose)
> > 9: the returned “myComp” is not initialized.
> > 10: the table tries to get its parameters from “myComp”
> > 11: null pointer exception
> >
> > Very simple. Seems like a trivial thing to do, doesn’t it?
> >
> >
> > -------------------- m2f --------------------
> >
> > Sent from www.TapestryForums.com
> >
> > Read this topic online here: <<topic_link>>
> >
> > http://www.tapestryforums.com/viewtopic.php?p=13315#13315
> >
> > -------------------- m2f --------------------
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> 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: re-instantiate components in a loop
Posted by Ron Piterman <rp...@gmx.net>.
Hallo Yael,
I never really used contrib:table but I guess, this happens because the
table uses the wrong link type for sorting, I guess the DirectLink, but
am not really sure about that -
instead you should "convince" the table to use ActionLink -
this will make the page rerender (before rendering the page for output,
also called rewinding) and the listener will be called during the
iteration of the For, so each component will have its binding set.
I would guess that the contrib:Table should be able to do that given the
right parameters.
Anyway, this is a case for Mind Bridge to tell...
Try posting again with something like: "changing contrib table sort
links ActionLink instead of DirectLink" in the subject...
Hope that helps,
Cheers,
Ron
yamsterdamer wrote:
> Hi Ron
> I think you pretty much got it right.
>
> For
> |___Component
> |___Contrib Table
>
> Step 1: the loop is rendering itself
> 2: in the first iteration a component with current parameters and an id, let's say “myComp” is being created, and renders itself
> 3: in the second iteration the same component with the id “myComp” is given different parameters, and renders itself again
> 4: and so on in the next iterations
> 5: the loop ends. The index/ value are deleted, and so is “myComp”
> 6: the page is displayed
> 7: the user presses sort link on one column of one of the tables.
> 8: the sort link requests for the component “myComp” (why? In order to retrieve table parameters from it, I suppose)
> 9: the returned “myComp” is not initialized.
> 10: the table tries to get its parameters from “myComp”
> 11: null pointer exception
>
> Very simple. Seems like a trivial thing to do, doesn’t it?
>
>
> -------------------- m2f --------------------
>
> Sent from www.TapestryForums.com
>
> Read this topic online here: <<topic_link>>
>
> http://www.tapestryforums.com/viewtopic.php?p=13315#13315
>
> -------------------- m2f --------------------
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: re-instantiate components in a loop
Posted by yamsterdamer <ma...@tapestryforums.com>.
Hi Ron
I think you pretty much got it right.
For
|___Component
|___Contrib Table
Step 1: the loop is rendering itself
2: in the first iteration a component with current parameters and an id, let's say myComp is being created, and renders itself
3: in the second iteration the same component with the id myComp is given different parameters, and renders itself again
4: and so on in the next iterations
5: the loop ends. The index/ value are deleted, and so is myComp
6: the page is displayed
7: the user presses sort link on one column of one of the tables.
8: the sort link requests for the component myComp (why? In order to retrieve table parameters from it, I suppose)
9: the returned myComp is not initialized.
10: the table tries to get its parameters from myComp
11: null pointer exception
Very simple. Seems like a trivial thing to do, doesnt it?
-------------------- m2f --------------------
Sent from www.TapestryForums.com
Read this topic online here: <<topic_link>>
http://www.tapestryforums.com/viewtopic.php?p=13315#13315
-------------------- m2f --------------------
Re: re-instantiate components in a loop
Posted by Ron Piterman <rp...@gmx.net>.
Hallo Yael,
you usually don't need to - what do you mean by "after rendering" -
If I get this right, you are trying to access a component which is
inside a loop from a component / method which is performed after the
loop is ended?
I still can't figure out what is bothering you or what you are trying to
achieve,
Cheers,
Ron
yamsterdamer wrote:
> The problem is not creating the page in the first time - that goes smoothly.
>
> Let me give you a more detailed description of the problem: I have a contrib table within my costume component. The link used to sort the table includes reference to the containing component using its id. But since the id is the same for all the appearances of the component created by the loop, I think what's happening is that tapestry goes to the html line that created the component and tries to re-create it using the value/index of the loop.
> And those are null, of course, after rendering the loop.
> The question is how can I instantiate a new component with a new Id in every iteration and save it with its parameters for later use (after rendering)?
>
>
> Yael.
>
>
> Ron Piterman wrote:
>
>>hallo yael,
>>I could not quite figure what the problem is -
>>what are you trying to achieve?
>>basically you should use components binding inside a For loop to make
>>each component render otherwise.
>>In the For, you use the value and index parameter bindings to set the
>>current iteration value/index to your page/component properties.
>>Then, in the components inside the For, you use those values (the
>>value/index properties) to configure each component differently.
>>Cheers,
>>Ron
>>
>>PS - why use the forum when you have a great mailing list ?
>>
>>yamsterdamer wrote:
>>
>>
>>>>Hi.
>>>>I'm using T4, and in some of my pages I create components within a loop.
>>>
>>>>>From what I have seen, seems like tapestry re-initializes the instance of the component with different parameters in each iteration, instead of instantiating a new component.
>>>
>>>>For example, looking at the component hierarchy on the run, I see that tapestry components like If, Insert etc are instantiated more than one time, getting ids like If_0, If_1. How can I do the same with mine? (again, within a loop!)
>>>>The ultimate goal is to allow each component to keep its own parameters, in order to use them later on re-render.
>>>>However, even a way of getting an indication to which component (index? Id? Location?) is being re-rendered will do for now…
>>>>Thanks a lot,
>>>>Yael.
>>>
>>>
>>>
>>> Sorry for the double posting, I really need help on this...
>>>
>>>
>>>
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>
> -------------------- m2f --------------------
>
> Sent from www.TapestryForums.com
>
> Read this topic online here: <<topic_link>>
>
> http://www.tapestryforums.com/viewtopic.php?p=13308#13308
>
> -------------------- m2f --------------------
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: re-instantiate components in a loop
Posted by yamsterdamer <ma...@tapestryforums.com>.
The problem is not creating the page in the first time - that goes smoothly.
Let me give you a more detailed description of the problem: I have a contrib table within my costume component. The link used to sort the table includes reference to the containing component using its id. But since the id is the same for all the appearances of the component created by the loop, I think what's happening is that tapestry goes to the html line that created the component and tries to re-create it using the value/index of the loop.
And those are null, of course, after rendering the loop.
The question is how can I instantiate a new component with a new Id in every iteration and save it with its parameters for later use (after rendering)?
Yael.
Ron Piterman wrote:
> hallo yael,
> I could not quite figure what the problem is -
> what are you trying to achieve?
> basically you should use components binding inside a For loop to make
> each component render otherwise.
> In the For, you use the value and index parameter bindings to set the
> current iteration value/index to your page/component properties.
> Then, in the components inside the For, you use those values (the
> value/index properties) to configure each component differently.
> Cheers,
> Ron
>
> PS - why use the forum when you have a great mailing list ?
>
> yamsterdamer wrote:
>
> > >Hi.
> > >I'm using T4, and in some of my pages I create components within a loop.
> > >From what I have seen, seems like tapestry re-initializes the instance of the component with different parameters in each iteration, instead of instantiating a new component.
> > >For example, looking at the component hierarchy on the run, I see that tapestry components like If, Insert etc are instantiated more than one time, getting ids like If_0, If_1. How can I do the same with mine? (again, within a loop!)
> > >The ultimate goal is to allow each component to keep its own parameters, in order to use them later on re-render.
> > >However, even a way of getting an indication to which component (index? Id? Location?) is being re-rendered will do for now
> > >Thanks a lot,
> > >Yael.
> >
> >
> > Sorry for the double posting, I really need help on this...
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
-------------------- m2f --------------------
Sent from www.TapestryForums.com
Read this topic online here: <<topic_link>>
http://www.tapestryforums.com/viewtopic.php?p=13308#13308
-------------------- m2f --------------------
Re: re-instantiate components in a loop
Posted by Ron Piterman <rp...@gmx.net>.
hallo yael,
I could not quite figure what the problem is -
what are you trying to achieve?
basically you should use components binding inside a For loop to make
each component render otherwise.
In the For, you use the value and index parameter bindings to set the
current iteration value/index to your page/component properties.
Then, in the components inside the For, you use those values (the
value/index properties) to configure each component differently.
Cheers,
Ron
PS - why use the forum when you have a great mailing list ?
yamsterdamer wrote:
>>Hi.
>>I'm using T4, and in some of my pages I create components within a loop.
>>>From what I have seen, seems like tapestry re-initializes the instance of the component with different parameters in each iteration, instead of instantiating a new component.
>>For example, looking at the component hierarchy on the run, I see that tapestry components like If, Insert etc are instantiated more than one time, getting ids like If_0, If_1. How can I do the same with mine? (again, within a loop!)
>>The ultimate goal is to allow each component to keep its own parameters, in order to use them later on re-render.
>>However, even a way of getting an indication to which component (index? Id? Location?) is being re-rendered will do for now…
>>Thanks a lot,
>>Yael.
>
>
> Sorry for the double posting, I really need help on this...
>
>
> -------------------- m2f --------------------
>
> Sent from www.TapestryForums.com
>
> Read this topic online here: <<topic_link>>
>
> http://www.tapestryforums.com/viewtopic.php?p=13299#13299
>
> -------------------- m2f --------------------
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org