The poll is a nice idea! I'm quite sure m. (IComponentResolver) is right. At the moment I can't figure out another way to "cheat" with missing components...
On Thu, Oct 7, 2021 at 2:37 PM Martijn Dashorst <martijn.dasho...@gmail.com> wrote: > @Julien HENRY <henr...@yahoo.fr> > > If you issue a return statement in a page constructor before the components > are added, what happens? > > 1. the page renders normally > 2. exception because missing components > > Now for the answer: typically 2 is correct. But that got me thinking of all > the ways you can have 1 as a result (this would be a great list for a > twitter thread) > > a. the components were added in a super-class constructor > b. the components were added in a sub-class constructor > c. the components were added in an onInitialize > d. the components were added in an onConfigure > e. the components were added in an onBeforeRender > f. the components were added using a Behavior (bad choice, but possible) > g. the page is invisible > h. the container that the components were added to is invisbile > i. the components are added in an IComponentInstantiationListener > j. the wicket:id's were escaped in the markup (e.g. awicket:id="...") > k. the components are added in an onInitialize of a child component (added > before the return, adding in child's constructor would fail because parent > is not know yet) > l. a custom RequestCycle adds the missing components in handleException, or > a IRequestCycleListener, or an IRequestHandler and restarts rendering (is > that necessary?) > m. an IComponentResolver creates the missing component(s) (not 100% sure > this works) > > Perhaps others can find insidious ways of adding components to a page? > > I think this would be quite a nice poll on twitter. > > Martijn > -- Andrea Del Bene. Apache Wicket committer.