Hi, I think it is safe to move it up. But let's see whether someone else sees an issue with this.
Martin Grigorov Wicket Training and Consulting https://twitter.com/mtgrigorov On Wed, Aug 6, 2014 at 12:20 PM, Guillaume Smet <[email protected]> wrote: > Hi all, > > We just got hit by a weird behavior of RefreshingView.onPopulate() and > I'm wondering if we could improve it or if there is a good reason for > the current order of the instructions in this method. > > The code of the method is as follows: > @Override > protected final void onPopulate() > { > Iterator<IModel<T>> models = getItemModels(); > Iterator<Item<T>> items = > getItemReuseStrategy().getItems(newItemFactory(), models, > getItems()); > removeAll(); > addItems(items); > } > > > We are using a DataView so getItemModels() loads the list of the > DataProvider. > > Our problem is that the removeAll() call which is done after that, > removes and detaches all the children of the RefreshingView > *including* components which detach the DataProvider when they are > detached. > > Hence after the onPopulate() call, our DataProvider is detached and if > a component needs to use the DataProvider, it needs to attach it again > and the query is executed again. > > So the obvious question: would it be possible to move the removeAll() > call at the beginning of the onPopulate() method or is there a good > reason to call removeAll() after the initialization? > > Thanks for your feedback! > > -- > Guillaume >
