Hi,

i am sorry that i didnt reply earlier. I forgot to mention that, when I close modal window with form, I show other modal window and it seems that javascript opens first window instead of new one.

On 10/27/2011 12:36 AM, Andrea Del Bene wrote:
Hi,
I've tried to reproduce your issue but without success. The modal window closes correctly. I've used the last version of Firefox, the 7. Java code for my test page is the following:

public class HomePage extends BasePage
{
    private static final long serialVersionUID = 1L;

    @Override
    protected void onInitialize() {
        super.onInitialize();

        final MyModal myModal = new MyModal("myModal");

        add(myModal);

        add(new AjaxLink("openForm") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                myModal.show(target);
            }
        });
    }

    class MyModal extends ModalWindow {

        public MyModal(String id) {
                super(id);
                MyPanel panel = new MyPanel(getContentId()) {
                    @Override
                    public void performAction(AjaxRequestTarget target) {
                        MyModal.this.close(target);
                    }
                };
                setContent(panel);

        }
    }


while the code for MyPanel is this:


public abstract class MyPanel extends Panel {

    public MyPanel(String id) {
        super(id);

        Form form = new Form("form");
                 add(form);
                 AjaxButton submit = new AjaxButton("submit") {

                    @Override
                    protected void onSubmit(AjaxRequestTarget target,
                            Form<?> form) {
                        performAction(target);

                    }
                    @Override
                    protected void onError(AjaxRequestTarget target,
                            Form<?> form) {
                    }
                   };
                form.add(submit);
    }
public abstract void performAction(AjaxRequestTarget target);
}
Thanks for quick reply. I close modal window in onError method of AjaxButton. Here is code:

public class MyModal extends ModalWindow {

    public MyModal(String id) {
            super(id);
            MyPanel panel = new MyPanel(getContentId()) {
                public void onError(AjaxRequestTarget target) {
MyModal.this.close(target);
                }
            }
            setContent(panel);

    }
}

and MyPanel class:

public abstract class MyPanel extends Panel {
    public MyPanel(String id) {
        super(id);
Form form = new Form("form);
         add(form);
         AjaxButton submit = new AjaxButton("submit) {
public void onError(AjaxRequestTarget target, Form<?> parent) {
                     MyPanel.this.onError(target);
              }
public void onSubmit(AjaxRequestTarget target, Form<?> parent) {
                    //process form
              }
            }
        form.add(submit);

        //remaining form components
    }

    public abstract void onError(AjaxRequestTarget target);
}




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to