Hi Sven,
An issue has been created for this with a quickstart: https://issues.apache.org/jira/browse/WICKET-5546 Regards Robin ________________________________ From: Sven Meier <[email protected]> To: [email protected] Sent: Friday, March 28, 2014 4:22 PM Subject: Re: Avoid calling Page.onInitialize if page constructor throws an exception Hi Robin, we should try to improve that. Please create a new issue with a quickstart. Thanks Sven On 03/28/2014 09:16 AM, Robin Shine wrote: > Hi Sven, > > Thanks for looking into this. I started a new wicket project from scratch > using Wicket maven archetype, and it does work as expected! Then I checked > into my project to find the difference, and tt turns out that this issue will > occur as long as below code is added in wicket WebApplication.init(): > > > getComponentInstantiationListeners().add(new >IComponentInstantiationListener() { > > @Override > public void onInstantiation(Component component) { > component.add(new Behavior() { > > }); > } > > }); > > It seems that the instantiation listener adds the behavior to the page at > very start of the page constructor, and then the page is marked as dirty to > cause onInitialize() being called afterwards. Is this a bug or expected > behavior? > > > Regards > Robin > > > > ________________________________ > From: Sven Meier <[email protected]> > To: [email protected] > Sent: Thursday, March 27, 2014 10:49 PM > Subject: Re: Avoid calling Page.onInitialize if page constructor throws an > exception > > > Hi, > > #onInitialize() is not called here with 6.14.0 and 6.15.0-SNAPSHOT. > > Regards > Sven > > > On 03/27/2014 03:30 PM, Robin Shine wrote: >> Hi All, >> >> We are glad to see that the issue WICKET-5387 (Page#onInitialize called >> after an exception in the constructor of Page) has been resolved in 6.13.0. >> However when I tried this version (and 6.14.0) with below code, the issue >> still exist: >> >> public class TestPage extends WebPage { >> >> public TestPage() { >> throw new RuntimeException("exception"); >> } >> >> @Override >> protected void onInitialize() { >> super.onInitialize(); >> >> System.out.println("onInitialize"); >> } >> >> } >> >> As you can see from above code, I intentionally throws an exception in >> TestPage constructor and hoping that onInitialize() method is not called >> when I visit that page. But the result is that "onInitialize" is still >> getting called in this case. Am I understanding WICKET-5387 incorrectly? And >> is there any approach to prevent onInitialize() from being called in case of >> a constructor exception? We want this as onInitialize() might rely on some >> params setup in the constructor, and calling onInitialize() will lead to >> other exceptions hiding exceptions thrown in constructor. >> >> Regards >> >> Robin >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
