Hi Philip,
ListView throws away all its children before rendering. When a component
is removed, its model gets detached.
Your AjaxLink has your LoadableDetachableModel as model, thus it forces
it to be detached too.
As a possible solution, don't keep a reference to the model as your
Sven,
Thanks for your speedy reply.
Indeed you are correct, removing the model from the AjaxLink stops the
model from becoming detached immediately before rendering.
I now realise that my cut-down example was too cut-down! The AjaxLink
is actually there to remove the entry from the list,
the problem here is that the listitem's model is tied to the
listview's model. so calling detach() on the listview item causes the
detachment of the listview's model.
you can either override getlistitemmodel() on the listview and give
each item an isolated model, or you can use a dataview or
you can ... give each item an isolated model
Actually ListItemModel doesn't detach the owning list's model, so it's
'isolated' already.
For your AjaxLink you can access the list view instead:
IModelListString model = ... // not final !!
final ListViewString rows = new
Thanks Sven, interesting idea however, rows is not accessible to
onClick() method as compilation error, rows not accessible as may
not be initialised. I guess Id have to getParent() loop until I found
a ListView component :(
Cheers, Phil.
On Mon, Jan 9, 2012 at 6:31 PM, Sven Meier
Ah, yes, stupid compiler ;).
You can keep the model final and use it on your onClick(), but *not*
passing it to the AjaxLink constructor:
final IModelListStringmodel = ... // final again !!
final ListViewStringrows = new ListViewString(rows, model)
{
Hi Sven,
OK thanks, that's good, with this..
final IModelListString model = new
LoadableDetachableModelListString()
{
@Override
protected ListString load()
{
System.out.println(LOAD LIST
Hi,
Can anyone tell me why when I refresh a wicket page which has on it an
AjaxLink, my list model is being detached just
before its contents are rendered by a list view?
I would expect detach only to be called after everything has been rendered.
Detaching just before rendering would call a