Hi Sven,

Thanks for clearing this up !

Cheers,
Tobias

Hi Tobias,

this is a well-known idiosyncrasy of a combination of ListView and LoadableDetachableModel:

Your delete button accesses the list item's model, thus loading the underlying list. Upon rendering the *old* list is rendered. When the next request comes in, the underlying list represents the actual contents after deleting an item.

Calling #detach() is ok, using an 'EntityModel' is an alternative - see ListView#getListItemModel() javadoc.

Have fun
Sven


Am 13.06.2017 um 13:35 schrieb Tobias Gierke:
Hi,

While trying to debug an AIOOBE that happens when a user opened the same page in multiple tabs (the page renders a repeater where users can remove items by clicking a button), I came across some interesting behaviour.

I created a tiny example project to show it: https://github.com/toby1984/wicket-ajaxtest

Observations:

1.) When you click on the very first button you notice that the AJAX response contains exactly the same same markup that is already present (so the page doesn't change) 2.) When you continue clicking on the buttons you will get an AIOOBE (caused by ListItemModel.java:61) while trying to delete the last item

These issues go away when I explicitly call detach() on the repeater's model after removing an item from the underlying list like so:

----->8---------->8---------->8---------->8---------->8---------->8---------->8----- final AjaxButton delete = new AjaxButton("deleteButton",item.getModel())
                {
                    @Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form)
                    {
                        final String obj = getModelObject();
                        db.remove( obj );
                        listModel.detach();
                        target.add( container );
                    }
                };
----->8---------->8---------->8---------->8---------->8---------->8---------->8-----

Is there a way to have this working properly without having to manually detach() after mutating the repeater model's list or is this the recommended approach ?

Thanks,
Tobias




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to