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
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to