Okay, here's my opinion:
People have been using Wicket for years now and this is the first bug of this type I have heard of. I am very reluctant attempt any sort of generic framework-level "fix" to the semantics of Java object construction (regardless of how anyone feels about the practices defined by the JLS). Java objects construct the way that they do and we use Java object constructors because we like that simplicity. Your bug is reported and will be fixed. Further, any other problem like this (and again, I've not heard of any) can be worked around using onAttach(). Chris Colman wrote: > > I have a constructor that takes parameters and then uses the parameters > to set up a variable that is used in getVariation(). > > There appears to be a lifecycle issue here because getVariation is being > called from within a base class constructor - before my constructor's > code below the super(parameters) has had a chance to get called. > Consequently getVariation() is called before the variable has been > initialized causing a NPE. > > Here's the stack dump: > > at com.MyPage.getVariation(MyPage.java:66) > at wicket.Component.getStyle(Component.java:1207) > at wicket.markup.MarkupCache.markupKey(MarkupCache.java:371) > at wicket.markup.MarkupCache.getMarkup(MarkupCache.java:166) > at wicket.markup.MarkupCache.getMarkupStream(MarkupCache.java:106) > at > wicket.MarkupContainer.getAssociatedMarkupStream(MarkupContainer.java:82 > 7) > at wicket.markup.html.WebPage.commonInit(WebPage.java:235) > at wicket.markup.html.WebPage.<init>(WebPage.java:120) > at com.sas.av.ui.wicket.templates.BasePage.<init>(BasePage.java:66) > at com.MyPage.<init>(MyPage.java:83) > > Often in these cases it serves the framework users well if the basic > construction takes place first and then, only after returning from the > instantiation, further initialization is performed - initialization that > might only work properly after all constructors have been fully > executed. > > Currently it appears possible for the getStyle and getVariation methods > to be invoked while a page is only semi constructed (ie., the > constructor stack has not unwound as shown above). > > Is there a current workaround for this or is it possible to readjust the > Wicket lifecycle model slightly to avoid this problem? > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Wicket-user mailing list > Wicket-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wicket-user > > -- View this message in context: http://www.nabble.com/Lifecycle-issue-with-getVariation-tf3476789.html#a9747403 Sent from the Wicket - User mailing list archive at Nabble.com. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user