how to change the panel data from a modal window opened from AjaxLink.onClick() ?
Hi all, dear wicket experts! I have some issue in my code, I suspect that it is because of ajax behavior, that I not quite understand. I have a MyPanel extends CheckedFolderT, that I create in NestedTree.newContentComponent() {}. This MyPanel has some public data, boolean bChanged for example. MyPanel has an AjaxLink that creates and shows a ModalWindow using for edit a MyPanel data. MyPanel.java public class MyPanel extends CheckedFolderT { public MyPanel(String id, AbstractTree tree, IModelT model, ModalWindow dialog, ...) { ... AjaxLink link = new AjaxLink(editlink, model) { public void onClick(AjaxRequestTarget target) { MyPanel.this.dialog.setWindowClosedCallback(new WindowClosedCallback() { public void onClose(AjaxRequestTarget target) { if*(bChanged == true)* { //update Panel model, to show an updated in ModalWindow data in a tree MyPanel.this.tree.updateNode(model.getObject(), target); } } } MyPanel.this.dialog.setPageCreator(new ModalWindow.PageCreator() { return new EditPage(MyPanel panel, ...); } MyPanel.this.dialog.show(target); } } } } In an EditPage I try to modify MyPanel.bChanged field when a user changed Panel data and try to close a Modal EditPage. EditPage.java ... protected void onSubmit(AjaxRequestTarget target, Form? form) { panel.bChanged = true; EditPage.this.modalWindow.close(target); } When ModalWindow closed, onClose(AjaxRequestTarget target) method in MyPanel fired. But a bChanged is always false in it. Why? And hence the more general question: How can I know that data in a modal EditPage is changed by user? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/how-to-change-the-panel-data-from-a-modal-window-opened-from-AjaxLink-onClick-tp4666216.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: how to change the panel data from a modal window opened from AjaxLink.onClick() ?
Addition: NestedTree and ModalWindow is placed on a TreePage: TreePage.html div wicket:id=modaleditdialog/div div wicket:id=tree[tree]/div TreePage.java public TreePage () { dialog = new ModalEditDialog(modaleditdialog); dialog.setResizable(true); dialog.setAutoSize(true); dialog.setOutputMarkupId(true); ... add(dialog); NestedTreeT nestedTree = new NestedTreeT(id, provider) { protected Component newContentComponent(String id, IModelT model) { MyPanel panel = new MyPanel(id, this, model, dialog,...); panel.setOutputMarkupId(true); return panel; } } nestedTree.setOutputMarkupId(true); add(nestedTree); ... } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/how-to-change-the-panel-data-from-a-modal-window-opened-from-AjaxLink-onClick-tp4666216p4666217.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: how to change the panel data from a modal window opened from AjaxLink.onClick() ?
Hi, The problem is that EditPage when deserialized creates a new copy of MyPanel instance and its bChanged member field. The best/simplest way is to use a Panel as ModalWindow content instead of a Page. Another way to share bChanged between the pages is to store it in the session (i.e. MySession#bChanged). Yet another way is to get a reference to bChanged thru the first page: - pass a PageReference of page1 to editpage and later use it: pageRef.getPage().setChanged(true) Martin Grigorov Wicket Training and Consulting On Thu, Jun 12, 2014 at 9:54 AM, Duke warlock9...@gmail.com wrote: Addition: NestedTree and ModalWindow is placed on a TreePage: TreePage.html div wicket:id=modaleditdialog/div div wicket:id=tree[tree]/div TreePage.java public TreePage () { dialog = new ModalEditDialog(modaleditdialog); dialog.setResizable(true); dialog.setAutoSize(true); dialog.setOutputMarkupId(true); ... add(dialog); NestedTreeT nestedTree = new NestedTreeT(id, provider) { protected Component newContentComponent(String id, IModelT model) { MyPanel panel = new MyPanel(id, this, model, dialog,...); panel.setOutputMarkupId(true); return panel; } } nestedTree.setOutputMarkupId(true); add(nestedTree); ... } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/how-to-change-the-panel-data-from-a-modal-window-opened-from-AjaxLink-onClick-tp4666216p4666217.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: how to change the panel data from a modal window opened from AjaxLink.onClick() ?
Thanks Martin! I tried to use a reference to bChanged through the first page, but it permanently bind ModalWindow with first page and I cant use it in another pages. For the first way - There will be no serialization/deserialization when I will use Panel insted of a Page in ModalWindow? Best regards, -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/how-to-change-the-panel-data-from-a-modal-window-opened-from-AjaxLink-onClick-tp4666216p4666227.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org