I need to select one of two links on the modal window and be able to redirect
user to the selected page. In order to accomplish that, I woudl expect to be
able to a) update the model object of the modal window from the appropriate
onClick (which seems to happen) and then b) to retrieve the new value of the
model object  within the WindowClosedCallback().onClose, but it does not
happen. I hope somebody can help. 

modal = new ModalWindow("modal", new Model<MyType>(MyType.FIRST_PAGE));
    (...)

  modal.setOutputMarkupId(true);
modal.setPageCreator(new ModalWindow.PageCreator()
   {
       public Page createPage()
                    {
                        return new
MyModalWindow(getPage().getPageReference(), modal, params);
                    }
                });
                
                target.appendJavaScript( "Wicket.Window.unloadConfirmation =
false;" ); 
                modal.show(target);


(...)

 public MyModalWindow(final PageReference modalWindowPage,
                                     final ModalWindow window,
                                     final PageParameters parameters) {

       
       window.setWindowClosedCallback(new ModalWindow.WindowClosedCallback()
{
            private static final long serialVersionUID = 1L;

            @Override
            public void onClose(AjaxRequestTarget target) {
           
                    System.out.println( window.getDefaultModelObject());
<--- Always the original FIRST_PAGE

         modalWindowPage.getPage()
                                    .setResponsePage(((MyType)
window.getDefaultModelObject()).equals(MyType.FIRST_PAGE) ? new
FirstPage(parameters)
                                            : new SecongPage(parameters));
               
            }
        });

 add(new AjaxLink<Void>("secondPage") {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {

               
           window.setDefaultModel(new Model<MyType>(MyType.SECOND_PAGE));
           System.out.println("NOW THE MODEL IS " +
window.getDefaultModelObject()); <-- ok, second page

                window.close(target);

            }

        });



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/ModalWindow-setWindowClosedCallback-has-access-to-old-model-tp4657672.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to