You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by Ricardo Lecheta <rl...@gmail.com> on 2008/09/29 16:20:59 UTC

This control's parent is already set to a Page

Hi all,

This exception breaks two of my applications.
I believe this doesn´t happen with click 1.4...

There are some use cases that is difficult to do with Click.

Let´s say I have a Form and Table.. In the table some "Edit" button. When
the user clicks in the edit button
I need show a new button in the Form. This button must appears only when the
user is editing the form.

And after that, the user can normally submit the form... or click in this
new button.
If the user clicks in this button, it must call it´s listener method of
course.

But now I have a problem because it is not in the Form, since I´m in other
request......
So I was used to let this kind of control as public,
so it is always added to the control list to be processed. But now if I do
that click throws this exception.

This is a very difficult use case to do... is it possible to not throw this
exception ?

regards,

-- 
Ricardo Lecheta

Re: This control's parent is already set to a Page

Posted by Bob Schellink <sa...@gmail.com>.
Thanks Ricardo, patch applied. :)


Ricardo Lecheta wrote:
> Hi Bob,
>
> the patch is here
> http://www.avoka.com:8080/jira/browse/CLK-449
>
> thanks
> Ricardo
>
> On Mon, Sep 29, 2008 at 3:36 PM, Bob Schellink <sa...@gmail.com> wrote:
>
>   
>> Hi Ricardo,
>>
>> Thats good to hear.
>>
>> I am going to cut a new release (RC2) in the next hour or so because of a
>> serious deployment bug.
>>
>> If you can open a JIRA and upload the patch I will include it for RC2.
>> (will also review before deployment)
>>
>> kind regards
>>
>> bob
>>
>>
>> Ricardo Lecheta wrote:
>>
>>     
>>> Hi Bob,
>>>
>>> it worked.
>>>
>>> On Mon, Sep 29, 2008 at 1:19 PM, Bob Schellink <sa...@gmail.com> wrote:
>>>
>>>
>>>
>>>       
>>>> Ricardo Lecheta wrote:
>>>>
>>>>
>>>>
>>>>         
>>>>> Noops, if you remove the Button from the page, it will be added to
>>>>> Form...
>>>>> and it will be processed, right?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>           
>>>> Ah yes, it should.
>>>>
>>>> Perhaps you could patch Page and AbstractContainer and see if it works
>>>> for
>>>> you. In other words
>>>> create a method Page#removeControl which reverses Page#addControl logic.
>>>> And in AbstractContainer#insert
>>>> instead of throwing exception, invoke Page#removeControl.
>>>>
>>>> Will that work in your case?
>>>>
>>>> regards
>>>>
>>>> bob
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>         
>>>
>>>
>>>       
>>     
>
>
>   


Re: This control's parent is already set to a Page

Posted by Ricardo Lecheta <rl...@gmail.com>.
Hi Bob,

the patch is here
http://www.avoka.com:8080/jira/browse/CLK-449

thanks
Ricardo

On Mon, Sep 29, 2008 at 3:36 PM, Bob Schellink <sa...@gmail.com> wrote:

> Hi Ricardo,
>
> Thats good to hear.
>
> I am going to cut a new release (RC2) in the next hour or so because of a
> serious deployment bug.
>
> If you can open a JIRA and upload the patch I will include it for RC2.
> (will also review before deployment)
>
> kind regards
>
> bob
>
>
> Ricardo Lecheta wrote:
>
>> Hi Bob,
>>
>> it worked.
>>
>> On Mon, Sep 29, 2008 at 1:19 PM, Bob Schellink <sa...@gmail.com> wrote:
>>
>>
>>
>>> Ricardo Lecheta wrote:
>>>
>>>
>>>
>>>> Noops, if you remove the Button from the page, it will be added to
>>>> Form...
>>>> and it will be processed, right?
>>>>
>>>>
>>>>
>>>>
>>> Ah yes, it should.
>>>
>>> Perhaps you could patch Page and AbstractContainer and see if it works
>>> for
>>> you. In other words
>>> create a method Page#removeControl which reverses Page#addControl logic.
>>> And in AbstractContainer#insert
>>> instead of throwing exception, invoke Page#removeControl.
>>>
>>> Will that work in your case?
>>>
>>> regards
>>>
>>> bob
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>


-- 
Ricardo Lecheta

Re: This control's parent is already set to a Page

Posted by Bob Schellink <sa...@gmail.com>.
Hi Ricardo,

Thats good to hear.

I am going to cut a new release (RC2) in the next hour or so because of 
a serious deployment bug.

If you can open a JIRA and upload the patch I will include it for RC2. 
(will also review before deployment)

kind regards

bob


Ricardo Lecheta wrote:
> Hi Bob,
>
> it worked.
>
> On Mon, Sep 29, 2008 at 1:19 PM, Bob Schellink <sa...@gmail.com> wrote:
>
>   
>> Ricardo Lecheta wrote:
>>
>>     
>>> Noops, if you remove the Button from the page, it will be added to Form...
>>> and it will be processed, right?
>>>
>>>
>>>       
>> Ah yes, it should.
>>
>> Perhaps you could patch Page and AbstractContainer and see if it works for
>> you. In other words
>> create a method Page#removeControl which reverses Page#addControl logic.
>> And in AbstractContainer#insert
>> instead of throwing exception, invoke Page#removeControl.
>>
>> Will that work in your case?
>>
>> regards
>>
>> bob
>>
>>
>>
>>     
>
>
>   


Re: This control's parent is already set to a Page

Posted by Ricardo Lecheta <rl...@gmail.com>.
Hi Bob,

it worked.

On Mon, Sep 29, 2008 at 1:19 PM, Bob Schellink <sa...@gmail.com> wrote:

> Ricardo Lecheta wrote:
>
>>
>> Noops, if you remove the Button from the page, it will be added to Form...
>> and it will be processed, right?
>>
>>
> Ah yes, it should.
>
> Perhaps you could patch Page and AbstractContainer and see if it works for
> you. In other words
> create a method Page#removeControl which reverses Page#addControl logic.
> And in AbstractContainer#insert
> instead of throwing exception, invoke Page#removeControl.
>
> Will that work in your case?
>
> regards
>
> bob
>
>
>


-- 
Ricardo Lecheta

Re: This control's parent is already set to a Page

Posted by Bob Schellink <sa...@gmail.com>.
Ricardo Lecheta wrote:
>
> Noops, if you remove the Button from the page, it will be added to Form...
> and it will be processed, right?
>   
Ah yes, it should.

Perhaps you could patch Page and AbstractContainer and see if it works 
for you. In other words
create a method Page#removeControl which reverses Page#addControl logic. 
And in AbstractContainer#insert
instead of throwing exception, invoke Page#removeControl.

Will that work in your case?

regards

bob



Re: This control's parent is already set to a Page

Posted by Ricardo Lecheta <rl...@gmail.com>.
Hi Bob,

>>Still this won't resolve Ricardo's use case as the Button will be removed
from the Page and thus not be processed.

Noops, if you remove the Button from the page, it will be added to Form...
and it will be processed, right?

On Mon, Sep 29, 2008 at 12:52 PM, Bob Schellink <sa...@gmail.com> wrote:

> I just notice that AbstarctContainer#insert has a TODO about this issue.
>
> Page does not expose a removeControl currently so we throw the exception.
> If we add a Page#removeControl
> method we could remove the Control from the Page instead of throwing the
> exception.
>
> Still this won't resolve Ricardo's use case as the Button will be removed
> from the Page and thus not be processed.
>
>
>
> Bob Schellink wrote:
>
>> Hi Ricardo,
>>
>> Think you should file a JIRA, we need to resolve this for 1.5 final.
>>
>> The exception acts as a sanity check. For example if you add the button to
>> the
>> Form and Page, what should button#getParent return? Page or Form? So on
>> one hand having the exception helps protect against mistakes, and on
>> another
>> it removes flexibility.
>>
>> In your case would it not be possible to create two separate buttons
>> instead?
>> They can both invoke the same listener.
>>
>> kind regards
>>
>> bob
>>
>> Ricardo Lecheta wrote:
>>
>>> Hi all,
>>>
>>> This exception breaks two of my applications.
>>> I believe this doesn´t happen with click 1.4...
>>>
>>> There are some use cases that is difficult to do with Click.
>>>
>>> Let´s say I have a Form and Table.. In the table some "Edit" button. When
>>> the user clicks in the edit button
>>> I need show a new button in the Form. This button must appears only when
>>> the
>>> user is editing the form.
>>>
>>> And after that, the user can normally submit the form... or click in this
>>> new button.
>>> If the user clicks in this button, it must call it´s listener method of
>>> course.
>>>
>>> But now I have a problem because it is not in the Form, since I´m in
>>> other
>>> request......
>>> So I was used to let this kind of control as public,
>>> so it is always added to the control list to be processed. But now if I
>>> do
>>> that click throws this exception.
>>>
>>> This is a very difficult use case to do... is it possible to not throw
>>> this
>>> exception ?
>>>
>>> regards,
>>>
>>>
>>>
>>
>>
>>
>


-- 
Ricardo Lecheta

Re: This control's parent is already set to a Page

Posted by Bob Schellink <sa...@gmail.com>.
I just notice that AbstarctContainer#insert has a TODO about this issue.

Page does not expose a removeControl currently so we throw the 
exception. If we add a Page#removeControl
method we could remove the Control from the Page instead of throwing the 
exception.

Still this won't resolve Ricardo's use case as the Button will be 
removed from the Page and thus not be processed.


Bob Schellink wrote:
> Hi Ricardo,
>
> Think you should file a JIRA, we need to resolve this for 1.5 final.
>
> The exception acts as a sanity check. For example if you add the 
> button to the
> Form and Page, what should button#getParent return? Page or Form? So on
> one hand having the exception helps protect against mistakes, and on 
> another
> it removes flexibility.
>
> In your case would it not be possible to create two separate buttons 
> instead?
> They can both invoke the same listener.
>
> kind regards
>
> bob
>
> Ricardo Lecheta wrote:
>> Hi all,
>>
>> This exception breaks two of my applications.
>> I believe this doesn´t happen with click 1.4...
>>
>> There are some use cases that is difficult to do with Click.
>>
>> Let´s say I have a Form and Table.. In the table some "Edit" button. 
>> When
>> the user clicks in the edit button
>> I need show a new button in the Form. This button must appears only 
>> when the
>> user is editing the form.
>>
>> And after that, the user can normally submit the form... or click in 
>> this
>> new button.
>> If the user clicks in this button, it must call it´s listener method of
>> course.
>>
>> But now I have a problem because it is not in the Form, since I´m in 
>> other
>> request......
>> So I was used to let this kind of control as public,
>> so it is always added to the control list to be processed. But now if 
>> I do
>> that click throws this exception.
>>
>> This is a very difficult use case to do... is it possible to not 
>> throw this
>> exception ?
>>
>> regards,
>>
>>   
>
>


Re: This control's parent is already set to a Page

Posted by Bob Schellink <sa...@gmail.com>.
Hi Ricardo,

Think you should file a JIRA, we need to resolve this for 1.5 final.

The exception acts as a sanity check. For example if you add the button 
to the
Form and Page, what should button#getParent return? Page or Form? So on
one hand having the exception helps protect against mistakes, and on another
it removes flexibility.

In your case would it not be possible to create two separate buttons 
instead?
They can both invoke the same listener.

kind regards

bob

Ricardo Lecheta wrote:
> Hi all,
>
> This exception breaks two of my applications.
> I believe this doesn´t happen with click 1.4...
>
> There are some use cases that is difficult to do with Click.
>
> Let´s say I have a Form and Table.. In the table some "Edit" button. When
> the user clicks in the edit button
> I need show a new button in the Form. This button must appears only when the
> user is editing the form.
>
> And after that, the user can normally submit the form... or click in this
> new button.
> If the user clicks in this button, it must call it´s listener method of
> course.
>
> But now I have a problem because it is not in the Form, since I´m in other
> request......
> So I was used to let this kind of control as public,
> so it is always added to the control list to be processed. But now if I do
> that click throws this exception.
>
> This is a very difficult use case to do... is it possible to not throw this
> exception ?
>
> regards,
>
>