You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Robin Shine <ro...@pmease.com> on 2011/03/07 04:33:25 UTC

Page.onPageAttached() never gets called in 1.5?

Hi All, 
We rely on this method to store the page instance being processed into a thread local so that we can easily get current page even from component constructors. In 1.4 this method is invoked after page is retrieved from session store for example when click an ajax link on the page. However in 1.5 it never gets called. Is this expected behavior or should I go ahead to create a bug? 
ThanksRobin

Re: Page.onPageAttached() never gets called in 1.5?

Posted by booloo <bd...@gmail.com>.
Hi,
We use the method onPageAttached () for  volidation, and if an error occurs
then we redirect to any appropriate page
>From the page constructor setResponsePage does not work. If you use the
if (! validateLogin ()) {
             throw new RestartResponseAtInterceptPageException
(LoginPage.class);
         }
as a result:
     Last cause: Same attribute found twice: key (line 21, column 70)
But there was not this error before. And on different pages we override
onPageAttached and add some new validations.
"public void onPageAttached() {
        super.onPageAttached();
        validate........"

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Page-onPageAttached-never-gets-called-in-1-5-tp3338320p4528292.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: Page.onPageAttached() never gets called in 1.5?

Posted by Igor Vaynberg <ig...@gmail.com>.
inside the listener you have access to the page.

move the creation of inner panels to the onInitialize() method, where
you are also guaranteed access to the page object.

problem solved.

-igor


On Mon, Mar 7, 2011 at 3:33 PM, Robin Shine <ro...@pmease.com> wrote:
> In the listener method, I had to replace some panels (and those panels in turn creates other panels). Since getPage() can not be invoked in component constructors, it will be necessary to pass the page instance retrieved in listener method as one of component constructor param in order to access page instance there.
> This might not be a common use case. Anyway, thanks for the extensive infrastructure of Wicket, I can call the onPageAttahched() method by myself by subclassing PersistentManagementPage.
> Regards
> Robin
>
> --- On Tue, 3/8/11, Igor Vaynberg <ig...@gmail.com> wrote:
>
> From: Igor Vaynberg <ig...@gmail.com>
> Subject: Re: Page.onPageAttached() never gets called in 1.5?
> To: users@wicket.apache.org
> Cc: "Robin Shine" <ro...@pmease.com>
> Date: Tuesday, March 8, 2011, 12:02 AM
>
> i dont seem to understand the entire usecase here, if you are running
> code inside a listener then you can get page via getpage()...
>
> -igor
>
> On Mon, Mar 7, 2011 at 12:33 AM, Robin Shine <ro...@pmease.com> wrote:
>> Hi Igor,
>> Thanks for the response. "onConfigure" gets called only when the page has to be rendered. Previously "onPageAttached" can serve as a hook point when page is loaded from page store even if it is not rendered, for example, when invoking listener interface on components contained in the page. Although I can override PagePersistentManager to call the hook by myself, but keeping this in Wicket 1.5 would be very convenient for some use cases, for example to get current page instance in component constructor without passing page instance as a constructor param.
>> Robin
>> --- On Mon, 3/7/11, Igor Vaynberg <ig...@gmail.com> wrote:
>>
>> From: Igor Vaynberg <ig...@gmail.com>
>> Subject: Re: Page.onPageAttached() never gets called in 1.5?
>> To: users@wicket.apache.org
>> Cc: "Robin Shine" <ro...@pmease.com>
>> Date: Monday, March 7, 2011, 1:27 PM
>>
>> i think this method should be removed from Page, for code that needs
>> access to a page you can use onInitialize() for one-time code and
>> onConfigure() for every request.
>>
>> -igor
>>
>> On Sun, Mar 6, 2011 at 7:33 PM, Robin Shine <ro...@pmease.com> wrote:
>>> Hi All,
>>> We rely on this method to store the page instance being processed into a thread local so that we can easily get current page even from component constructors. In 1.4 this method is invoked after page is retrieved from session store for example when click an ajax link on the page. However in 1.5 it never gets called. Is this expected behavior or should I go ahead to create a bug?
>>> ThanksRobin
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Page.onPageAttached() never gets called in 1.5?

Posted by Robin Shine <ro...@pmease.com>.
In the listener method, I had to replace some panels (and those panels in turn creates other panels). Since getPage() can not be invoked in component constructors, it will be necessary to pass the page instance retrieved in listener method as one of component constructor param in order to access page instance there. 
This might not be a common use case. Anyway, thanks for the extensive infrastructure of Wicket, I can call the onPageAttahched() method by myself by subclassing PersistentManagementPage. 
Regards
Robin

--- On Tue, 3/8/11, Igor Vaynberg <ig...@gmail.com> wrote:

From: Igor Vaynberg <ig...@gmail.com>
Subject: Re: Page.onPageAttached() never gets called in 1.5?
To: users@wicket.apache.org
Cc: "Robin Shine" <ro...@pmease.com>
Date: Tuesday, March 8, 2011, 12:02 AM

i dont seem to understand the entire usecase here, if you are running
code inside a listener then you can get page via getpage()...

-igor

On Mon, Mar 7, 2011 at 12:33 AM, Robin Shine <ro...@pmease.com> wrote:
> Hi Igor,
> Thanks for the response. "onConfigure" gets called only when the page has to be rendered. Previously "onPageAttached" can serve as a hook point when page is loaded from page store even if it is not rendered, for example, when invoking listener interface on components contained in the page. Although I can override PagePersistentManager to call the hook by myself, but keeping this in Wicket 1.5 would be very convenient for some use cases, for example to get current page instance in component constructor without passing page instance as a constructor param.
> Robin
> --- On Mon, 3/7/11, Igor Vaynberg <ig...@gmail.com> wrote:
>
> From: Igor Vaynberg <ig...@gmail.com>
> Subject: Re: Page.onPageAttached() never gets called in 1.5?
> To: users@wicket.apache.org
> Cc: "Robin Shine" <ro...@pmease.com>
> Date: Monday, March 7, 2011, 1:27 PM
>
> i think this method should be removed from Page, for code that needs
> access to a page you can use onInitialize() for one-time code and
> onConfigure() for every request.
>
> -igor
>
> On Sun, Mar 6, 2011 at 7:33 PM, Robin Shine <ro...@pmease.com> wrote:
>> Hi All,
>> We rely on this method to store the page instance being processed into a thread local so that we can easily get current page even from component constructors. In 1.4 this method is invoked after page is retrieved from session store for example when click an ajax link on the page. However in 1.5 it never gets called. Is this expected behavior or should I go ahead to create a bug?
>> ThanksRobin
>

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


Re: Page.onPageAttached() never gets called in 1.5?

Posted by Igor Vaynberg <ig...@gmail.com>.
i dont seem to understand the entire usecase here, if you are running
code inside a listener then you can get page via getpage()...

-igor

On Mon, Mar 7, 2011 at 12:33 AM, Robin Shine <ro...@pmease.com> wrote:
> Hi Igor,
> Thanks for the response. "onConfigure" gets called only when the page has to be rendered. Previously "onPageAttached" can serve as a hook point when page is loaded from page store even if it is not rendered, for example, when invoking listener interface on components contained in the page. Although I can override PagePersistentManager to call the hook by myself, but keeping this in Wicket 1.5 would be very convenient for some use cases, for example to get current page instance in component constructor without passing page instance as a constructor param.
> Robin
> --- On Mon, 3/7/11, Igor Vaynberg <ig...@gmail.com> wrote:
>
> From: Igor Vaynberg <ig...@gmail.com>
> Subject: Re: Page.onPageAttached() never gets called in 1.5?
> To: users@wicket.apache.org
> Cc: "Robin Shine" <ro...@pmease.com>
> Date: Monday, March 7, 2011, 1:27 PM
>
> i think this method should be removed from Page, for code that needs
> access to a page you can use onInitialize() for one-time code and
> onConfigure() for every request.
>
> -igor
>
> On Sun, Mar 6, 2011 at 7:33 PM, Robin Shine <ro...@pmease.com> wrote:
>> Hi All,
>> We rely on this method to store the page instance being processed into a thread local so that we can easily get current page even from component constructors. In 1.4 this method is invoked after page is retrieved from session store for example when click an ajax link on the page. However in 1.5 it never gets called. Is this expected behavior or should I go ahead to create a bug?
>> ThanksRobin
>

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


Re: Page.onPageAttached() never gets called in 1.5?

Posted by Robin Shine <ro...@pmease.com>.
Hi Igor, 
Thanks for the response. "onConfigure" gets called only when the page has to be rendered. Previously "onPageAttached" can serve as a hook point when page is loaded from page store even if it is not rendered, for example, when invoking listener interface on components contained in the page. Although I can override PagePersistentManager to call the hook by myself, but keeping this in Wicket 1.5 would be very convenient for some use cases, for example to get current page instance in component constructor without passing page instance as a constructor param.
Robin
--- On Mon, 3/7/11, Igor Vaynberg <ig...@gmail.com> wrote:

From: Igor Vaynberg <ig...@gmail.com>
Subject: Re: Page.onPageAttached() never gets called in 1.5?
To: users@wicket.apache.org
Cc: "Robin Shine" <ro...@pmease.com>
Date: Monday, March 7, 2011, 1:27 PM

i think this method should be removed from Page, for code that needs
access to a page you can use onInitialize() for one-time code and
onConfigure() for every request.

-igor

On Sun, Mar 6, 2011 at 7:33 PM, Robin Shine <ro...@pmease.com> wrote:
> Hi All,
> We rely on this method to store the page instance being processed into a thread local so that we can easily get current page even from component constructors. In 1.4 this method is invoked after page is retrieved from session store for example when click an ajax link on the page. However in 1.5 it never gets called. Is this expected behavior or should I go ahead to create a bug?
> ThanksRobin

Re: Page.onPageAttached() never gets called in 1.5?

Posted by Igor Vaynberg <ig...@gmail.com>.
i think this method should be removed from Page, for code that needs
access to a page you can use onInitialize() for one-time code and
onConfigure() for every request.

-igor

On Sun, Mar 6, 2011 at 7:33 PM, Robin Shine <ro...@pmease.com> wrote:
> Hi All,
> We rely on this method to store the page instance being processed into a thread local so that we can easily get current page even from component constructors. In 1.4 this method is invoked after page is retrieved from session store for example when click an ajax link on the page. However in 1.5 it never gets called. Is this expected behavior or should I go ahead to create a bug?
> ThanksRobin

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