Hi,

I've run a cross a small dilemma while teaching one of my employees Wicket. On his first project he created a ListView that pulls data from a LoadableDetachableModel. He overrides isVisible on the ListView, and does:

@Override public boolean isVisible() {
        return ((List)myModel.getObject()).size() > 0;
}

.. so the list won't be visible if the list is empty.

In the ListView ha has a button that deletes items. The code was originally:

item.add(new Link("delete") {
        @Override public void onClick() {
                myDao.delete(item.getModelObject());
        }
});

When he clicks the delete-link, isVisible() for the ListView is called BEFORE the onClick() action, and since it is a LoadableDetachableModel, it then holds the data from the list as it was before the row is deleted. The result is ofcourse that the deleted object is still in the list when the page rerenders, which forces him to include a setResponsePage(TheListPage.class) instead of just letting the ListView reuse items and render itself again.

It's a bit of a surprice that isVisible() is called before the onClick() method. I understand that this has to do with the flow of things in Wicket, but if someone can shed some light as to why/how, I'd ble glad to contribute a Wicket page explaining this dilemma and how to get around it, as I'm sure people run into this problem regularily.

-- Edvin




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to