You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Vikram Natarajan <vn...@pogohealth.com> on 2008/11/19 22:57:09 UTC
StateFul Page question
I have a Page subclassing a BorderTemplate Page which adds a control
("Login/Logout" - a PageLink named "logoutLink").
When I make the subclassed Page stateful, I get an Exception that the
"model" already contains value named "logoutLink" when I submit the form
on this page.
When I set stateful to false, I don't get the exception.
What am I doing wrong here? Thanks for your help in advance.
--
Thanks,
Vikram Natarajan
Re: StateFul Page question
Posted by Bob Schellink <sa...@gmail.com>.
Vikram Natarajan wrote:
>
> That was exactly what I was doing and am working on fixing this. Thanks
> for your help and I will try to read the documentation before I shoot
> off an email.
Not everyone like reading docs upfront myself included. First get the
hands dirty :)
Re: StateFul Page question
Posted by Vikram Natarajan <vn...@pogohealth.com>.
Hi Bob
That was exactly what I was doing and am working on fixing this. Thanks
for your help and I will try to read the documentation before I shoot
off an email.
Thanks
Vikram
Bob Schellink wrote:
> Hi Vikram,
>
> When you set Pages to stateful they are constructed once and reused
> between requests. Thus their constructor is only called once, but they
> still go through the same lifecycle of onInit, onProcess, onGet etc.
>
> What is most likely happening is that you add the logoutLink in the
> onInit phase meaning on the second request to a stateful page, the
> link is added for a second time and Click complains.
>
> If you want to use a stateful page its best to add controls in the
> Page constructor not the onInit phase.
>
> See section 8.1:
> http://click.sourceforge.net/docs/pages.html#page-stateful
>
> Does that help?
>
> kind regards
>
> bob
>
>
> Vikram Natarajan wrote:
>>
>> I have a Page subclassing a BorderTemplate Page which adds a control
>> ("Login/Logout" - a PageLink named "logoutLink").
>>
>> When I make the subclassed Page stateful, I get an Exception that the
>> "model" already contains value named "logoutLink" when I submit the
>> form on this page.
>> When I set stateful to false, I don't get the exception.
>>
>> What am I doing wrong here? Thanks for your help in advance.
>>
>
Re: StateFul Page question
Posted by Bob Schellink <sa...@gmail.com>.
Hi Vikram,
When you set Pages to stateful they are constructed once and reused
between requests. Thus their constructor is only called once, but they
still go through the same lifecycle of onInit, onProcess, onGet etc.
What is most likely happening is that you add the logoutLink in the
onInit phase meaning on the second request to a stateful page, the
link is added for a second time and Click complains.
If you want to use a stateful page its best to add controls in the
Page constructor not the onInit phase.
See section 8.1:
http://click.sourceforge.net/docs/pages.html#page-stateful
Does that help?
kind regards
bob
Vikram Natarajan wrote:
>
> I have a Page subclassing a BorderTemplate Page which adds a control
> ("Login/Logout" - a PageLink named "logoutLink").
>
> When I make the subclassed Page stateful, I get an Exception that the
> "model" already contains value named "logoutLink" when I submit the form
> on this page.
> When I set stateful to false, I don't get the exception.
>
> What am I doing wrong here? Thanks for your help in advance.
>