Refreshing Listbox after deleting an item/row
5 Feb 2012 13:59:53 GMT
6 Feb 2012 04:02:35 GMT
6 Feb 2012 04:02:35 GMT
Hi,
You have to get the "binder" in the messagebox event and call the loadComponent(component) API or loadAll() API to refresh the page.
public void onClick$deleteButton() throws InterruptedException {
Messagebox.show("Are you sure to delete?", "Confirm", Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION,
new EventListener() {
public void onEvent(Event event) throws Exception {
if (((Integer) event.getData()).intValue() == Messagebox.OK) {
// process deletion here...
AnnotateDataBinder binder = (AnnotateDataBinder) page.getAttribute("binder");
binder.loadAll();
}
}
});
}
16 Feb 2012 23:02:16 GMT
16 Feb 2012 23:02:16 GMT
Hi vincentjian,
this es EXACTLY what I was looking for! And it works perfectly well.
Thank you in advance!
Andreas
11 May 2012 11:36:13 GMT
11 May 2012 11:36:13 GMT
Hi, vincentjian.
Your answer really helped me, too. It saved me a lot of code...
Thank you very much for share it!
Airton
ZK - Open Source Ajax Java Framework
Hi ZK users,
I have a Listbox with databinding enabled. I have registered three buttons to manage the entries by adding "load-after='add.onClick, delete.onClick, update.onClick'" on the model-definition of the Listbox.
Everything works fine as expected, but now I want to add a confirmation to the delete-operation. I have created a Messagebox with a event-handler and the dialog works, so the item is removed/deleted but I need to manually refresh the page to see the changes happen.
The load-after seems to do what it's expected to do, right after hitting the "delete" button, but at this time the confirmation dialog is created and the item has not yet been deleted. I have tried to manually refresh the Listbox with ".invalidate();" which does not work for me. At the moment I do a "Executions.sendRedirect("");" which forces a reload of the whole page but this is not exactly what I want.
Can I register the "load-after" event handler to the ok button of my Messagebox or what is the general approach of integrating a confirmation-dialog to a delete-button?
Thank you for your help!
Andreas