Please refer the below formatted code snippet. I'm setting selectedRow value in page creator and expecting the same in window close call back (Line number 24), I tried with the Inter component communication examples as you suggested. But I don't know how to update the selectedRow in line #24 with onEven(IEvent<?> event).
Paste Bin URL: http://pastebin.com/Y2KA2LNn 1. 2. public class FieldSearchTextField extends MaskedTextField{ 3. ResultRow selectedRow; 4. 5. /* other business code here*/ 6. 7. /* page creator */ 8. modalWindow.setPageCreator (new ModalWindow.PageCreator() { 9. public Page createPage() { 10. FieldSearchModalPage casePartyModalPage = new FieldSearchModalPage(searchOption, modalWindow){ 11. @Override 12. public void updateValue(ResultRow row, AjaxRequestTarget target) { 13. selectedRow = row; /* selectedRow is not null here*/ 14. getPageReference().getPage().send( getPage(), Broadcast.BREADTH,new GridValueChangeEvent(target)); 15. } 16. } 17. } 18. } 19. 20. /* window close call back*/ 21. modalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { 22. @Override 23. public void onClose(AjaxRequestTarget target) { 24. /* how to get the selectedRow value here????? */ 25. onFieldSearchWindowClose(selectedRow, target);*// selectedRow is null here.* 26. } 27. } 28. 29. /*onEvent implementation*/ 30. @Override 31. public void onEvent(IEvent<?> event) { 32. super.onEvent(event); 33. if(event.getPayload() instanceof GridValueChangeEvent) { 34. GridValueChangeEvent gridValueChangeEvent = ((GridValueChangeEvent) event. 35. getPayload()); 36. gridValueChangeEvent.getTarget().add(this); 37. } 38. } 39. /* Grid value change event class*/ 40. public class GridValueChangeEvent { 41. private final AjaxRequestTarget target; 42. 43. public GridValueChangeEvent(AjaxRequestTarget target) { 44. this.target = target; 45. } 46. public AjaxRequestTarget getTarget() { 47. return target; 48. } 49. } 50. 51. } On Fri, Apr 22, 2016 at 4:53 PM, Martin Grigorov <mgrigo...@apache.org> wrote: > Please use some pastebin service. > It is hard to read and follow this code. > > Martin Grigorov > Wicket Training and Consulting > https://twitter.com/mtgrigorov > > On Fri, Apr 22, 2016 at 10:43 PM, durairaj t <durairaj....@gmail.com> > wrote: > > > Thank you Martin. I tried with examples but those are not working in my > > case. I don't know how to call the onEvent in line number 19 in the below > > code snippet. Please share me if you have any examples. > > > > > > 1. public class FieldSearchTextField extends MaskedTextField{ > > 2. ResultRow selectedRow; > > 3. /* page creator */ > > 4. modalWindow.setPageCreator (new ModalWindow.PageCreator() { > > 5. public Page createPage() { > > 6. FieldSearchModalPage casePartyModalPage = new > > FieldSearchModalPage(searchOption, modalWindow){ > > 7. @Override > > 8. public void updateValue(ResultRow row, AjaxRequestTarget target) { > > 9. selectedRow = row;* //selectedRow is not null here* > > 10. getPageReference().getPage().send( getPage(), Broadcast.BREADTH,new > > GridValueChangeEvent(target)); > > 11. } > > 12. } > > 13. } > > 14. } > > 15. /* window close call back*/ > > 16. modalWindow.setWindowClosedCallback(new > > ModalWindow.WindowClosedCallback() { > > 17. @Override > > 18. public void onClose(AjaxRequestTarget target) { > > 19. *??????????????????????????????* > > 20. onFieldSearchWindowClose(selectedRow, target);*// selectedRow is > > null here.* > > 21. } > > 22. } > > 23. @Override > > 24. public void onEvent(IEvent event) { > > 25. if(event.getPayload() instanceof GridValueChangeEvent) { > > 26. GridValueChangeEvent gridValueChangeEvent = ((GridValueChangeEvent) > > event.getPayload()); > > 27. } > > 28. } > > 29. } > > 30. > > > > > > On Sat, Apr 16, 2016 at 3:03 PM, Martin Grigorov <mgrigo...@apache.org> > > wrote: > > > > > Hi, > > > > > > The problem is the same. > > > In your first question you were asking for MyPanel.this, now you ask > for > > > TextField.this. > > > > > > If you cannot use Panel backed ModalWindow then use > > > pageRef.getPage().send(pageRef.getPage(), Broadcast.BREADTH, new > > > MyModalClosedEvent()) and listen for this event in all components which > > > should be repainted. > > > > > > Martin Grigorov > > > Wicket Training and Consulting > > > https://twitter.com/mtgrigorov > > > > > > On Fri, Apr 15, 2016 at 4:01 PM, durairaj t <durairaj....@gmail.com> > > > wrote: > > > > > > > "openerPage.getPageReference()" is working with the pages, not in > the > > > > customized wicket component classes (like TextField and Panels..etc). > > do > > > we > > > > have any other way to get the modified objects from the customized > > > > component classes? > > > > > > > > for example; > > > > ------------------ > > > > public class FieldSearchTextField extends MaskedTextField{ > > > > > > > > ResultRow selectedRow; > > > > > > > > /* window close call back*/ > > > > > > > > modalWindow.setWindowClosedCallback(new > > > > ModalWindow.WindowClosedCallback() { > > > > @Override > > > > public void onClose(AjaxRequestTarget target) > > > > { > > > > onFieldSearchWindowClose(selectedRow, target);*// selectedRow is > > null > > > > here.* > > > > } > > > > > > > > /* page creator */ > > > > > > > > modalWindow.setPageCreator (new ModalWindow.PageCreator() { > > > > public Page createPage() { > > > > FieldSearchModalPage casePartyModalPage = new > > > > FieldSearchModalPage(searchOption, modalWindow){ > > > > @Override > > > > public void updateValue(ResultRow row, AjaxRequestTarget target) { > > > > selectedRow = row;* //selectedRow is not null here* > > > > } > > > > } > > > > } > > > > } > > > > > > > > > > > > Parent classes: > > > > ------------------------- > > > > public class MaskedTextField extends StringTextField implements > > > > ITextFormatProvider {} > > > > public class StringTextField extends ErroringTextField<String> {} > > > > public class ErroringTextField<T> extends TextField<T> {} > > > > > > > > Like "MyTextFieldPanel" I'm not getting modified values in the > > customized > > > > components. This is the cases I'm facing in all the customized > > components > > > > not only in the "MyTextFieldPanel". > > > > > > > > > > > > Any help? > > > > > > > > > > > > On Tue, Apr 12, 2016 at 4:54 AM, Martin Grigorov < > mgrigo...@apache.org > > > > > > > wrote: > > > > > > > > > Hi, > > > > > > > > > > If you use ModalWindow based on a Page then you have to keep a > > > reference > > > > to > > > > > that page by using openerPage.getPageReference(). > > > > > Later when you need to update the opener page you have to use > > > > > "pageRef.getPage()". > > > > > You can see > > > > > > > > > > > > > > > > > > > > https://github.com/apache/wicket/blob/686058119dd795b3de7f2016e3e64fb8f025f813/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/modal/ModalContent1Page.java > > > > > for example. > > > > > > > > > > The problem in your case is that the opener's instance of > > > > MyTextFieldPanel > > > > > is serialized when the modal window's page is opened. Later when > you > > > > close > > > > > the modal it works on the old version, not the latest one that is > > > > > deserialized with the opener page. > > > > > > > > > > If you use ModalWindow with a Panel then there is no such issue. > > > > > > > > > > Martin Grigorov > > > > > Wicket Training and Consulting > > > > > https://twitter.com/mtgrigorov > > > > > > > > > > On Mon, Apr 11, 2016 at 10:42 PM, durairaj t < > durairaj....@gmail.com > > > > > > > > wrote: > > > > > > > > > > > Hi, > > > > > > > > > > > > > > > > > > > > > > > > I'm using "*new* ModalWindow.WindowClosedCallback(){}" to update > > the > > > > > > modified value in a text field box by invoking the * target.add(* > > > > > > *MyTextFieldPanel.this**)*, but it is always giving the old > values. > > > > > > > > > > > > > > > > > > I'm seeing only old values in *MyTextFieldPanel.this. * > > > > > > > > > > > > > > > > > > Code snippet for a clear picture. > > > > > > > > > > > > > > > > > > public class AimShuttleTextFieldPanel extends Panel > > > > > > > > > > > > > > > > > > modalShuttleWindow.setWindowClosedCallback(new > > > > > > ModalWindow.WindowClosedCallback() { > > > > > > > > > > > > public void onClose(AjaxRequestTarget target) { > > > > > > > > > > > > target.add(*MyTextFieldPanel.this*); > > > > > > > > > > > > onWindowClose(target); > > > > > > > > > > > > } > > > > > > > > > > > > }); > > > > > > > > > > > > > > > > > > Any help? > > > > > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > > > > > > > > > > > > > >