I don't like the whole idea of re-adding component. Wizard is the only component in Wicket distro which fails the org.apache.wicket.core.util.objects.checker.OrphanComponentChecker. I think only the data (i.e. the models) should be kept around and the components should be re-created for every view of that data when this is needed. For me Wizard component is a bad practice.
Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Mon, Aug 18, 2014 at 1:07 PM, Carl-Eric Menzel <cmen...@wicketbuch.de> wrote: > One difficulty I am finding: > > If I do not simply fire onAdd for everything that gets added, then I > have to differentiate. What do I do if I re-add a container that is > already initialized, so its onReAdd should be called, but which has a > new child that is not initialized? Which event should happen in the > child, and how should it be propagated? Or the other way around, what > if I have a new container but an already initialized child? If the > container checks whether it is initialized before calling onReAdd on > its children, then the child would not receive the onReAdd. > > This may look complicated, but I don't think it is a problem with the > idea of having an onAdd or onReAdd. It is rather a consequence of the > fact that Wicket allows components to be removed and added again in > different compositions. You can remove a subtree and then add a new > subtree that can have some of the old components. > > In light of this, I am in favor of having a general onAdd that is > always called, and to more clearly document that onInitialize is > supposed to be a delayed constructor. > > Carl-Eric > > On Mon, 18 Aug 2014 13:00:26 +0200 > Martin Grigorov <mgrigo...@apache.org> wrote: > > > Wait for some more opinions. > > > > Martin Grigorov > > Wicket Training and Consulting > > https://twitter.com/mtgrigorov > > > > > > On Mon, Aug 18, 2014 at 12:38 PM, Carl-Eric Menzel > > <cmen...@wicketbuch.de> wrote: > > > > > On Mon, 18 Aug 2014 11:49:51 +0200 > > > Martin Grigorov <mgrigo...@apache.org> wrote: > > > > > > > Hi, > > > > > > > > I still find it confusing :-/ > > > > > > > > 1) with this we will have: the constructor, onInitialize() and > > > > onAddToPage() being called as component initializers. Way too much > > > > IMO. onInitialize() and onAddToPage() are exactly the same thing > > > > at this stage. > > > > > > At this stage, yes. > > > > > > > 2) onRemove() is not named onRemoveFromPage(). (I don't like the > > > > name onAddToPage()) > > > > > > I'm not invested in the name, so that can be changed :-) > > > > > > > Is it possible to redo it as onReAdd(), i.e. it will be called > > > > when the component is added to a parent and it is already > > > > initialized. Not sure but maybe all that is needed to do it is to > > > > remove the call to onAddToPage() in onInitialize(), and rename > > > > the method. > > > > > > Hm. That means that if I want to always react to being added, I'd > > > have to do it in both onInitialize and onReAdd. > > > > > > However, I can see that it would potentially remove some confusion > > > by more clearly defining the difference between the two. > > > > > > I'll give it a try and update the branch. > > > > > > Carl-Eric > > > > >