Example usage for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow close

List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow close

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow close.

Prototype

public void close(final IPartialPageRequestHandler target) 

Source Link

Document

Closes the modal window.

Usage

From source file:de.widone.web.page.base.BasePage.java

License:Apache License

public BasePage() {
    super();/*  ww w . j  a  va  2  s .  co  m*/
    final ModalWindow modalWindow = new ModalWindow("modalWindow");
    modalWindow.setContent(new UserDetailsPanel(modalWindow.getContentId(), new CurrentUserModel()));
    modalWindow.add(new Behavior() {
        @Override
        public void onEvent(Component component, IEvent<?> event) {
            if (event.getPayload() instanceof CancelEvent) {
                modalWindow.close(((CancelEvent) event.getPayload()).getTarget());
            }
        }
    });
    add(new Label("loginName", new StringResourceModel("loginName", this,
            new CompoundPropertyModel<User>(((WiDoneSession) WebSession.get()).getUser()))));
    add(modalWindow);
    add(new AjaxFallbackLink<Void>("userDetails") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            target.appendJavaScript("Wicket.Window.unloadConfirmation = false;");
            modalWindow.show(target);
        }
    });
    add(new AjaxFallbackLink<Void>("logout") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            WebSession.get().invalidate();
            setResponsePage(SignInPage.class);
        }
    });
}

From source file:gr.abiss.calipso.wicket.EditFieldGroupPanel.java

License:Open Source License

/**
 * just closes the window, override to actually persist
 * @param modalWindow/*from  w  w w  .j  av a 2s. c  om*/
 * @param fieldGroupForm
 * @return
 */
protected AjaxButton getSaveButton(final ModalWindow modalWindow, Form<FieldGroup> fieldGroupForm,
        final FeedbackPanel feedbackPanel) {
    AjaxButton save = new IndicatingAjaxButton(BUTTON_SAVE, fieldGroupForm) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            log.warn("method getSaveButton was given as an example but not overriden.");
            persist(target, form);
            if (target != null) {
                modalWindow.close(target);
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form form) {
            log.warn("method getSaveButton was given as an example but not overriden.");
            if (target != null) {
                target.addComponent(feedbackPanel);
            }
        }
    };
    return save;
}

From source file:gr.abiss.calipso.wicket.EditFieldGroupPanel.java

License:Open Source License

protected AjaxButton getCancelButton(final ModalWindow modalWindow, Form<FieldGroup> fieldGroupForm) {
    AjaxButton cancel = new AjaxButton(BUTTON_CANCEL, fieldGroupForm) {

        @Override//from  ww  w  .jav a 2 s .com
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            if (target != null) {
                modalWindow.close(target);
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            // TODO Auto-generated method stub

        }
    };
    return cancel;
}

From source file:gr.abiss.calipso.wicket.EditItemRenderingTemplatePanel.java

License:Open Source License

/**
 * just closes the window, override to actually persist
 * /*w ww  .  j a v  a  2 s  .  c  om*/
 * @param modalWindow
 * @param itemRenderingTemplateForm
 * @return
 */
protected AjaxButton getSaveButton(final ModalWindow modalWindow,
        Form<ItemRenderingTemplate> itemRenderingTemplateForm, final FeedbackPanel feedbackPanel) {
    AjaxButton save = new IndicatingAjaxButton(BUTTON_SAVE, itemRenderingTemplateForm) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            persist(target, form);
            if (target != null) {
                target.prependJavaScript("removeEditors();");
                modalWindow.close(target);
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form form) {
            if (target != null) {
                target.addComponent(feedbackPanel);
            }
        }
    };
    save.add(new TinyMceAjaxSubmitModifier());
    return save;
}

From source file:gr.abiss.calipso.wicket.EditItemRenderingTemplatePanel.java

License:Open Source License

protected AjaxButton getCancelButton(final ModalWindow modalWindow,
        Form<ItemRenderingTemplate> itemRenderingTemplateForm) {
    AjaxButton cancel = new AjaxButton(BUTTON_CANCEL, itemRenderingTemplateForm) {

        @Override//from w w w.  j  a  v a  2s .c  o m
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            if (target != null) {
                target.prependJavaScript("removeEditors();");
                modalWindow.close(target);
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
        }

    };
    return cancel;
}

From source file:hsa.awp.admingui.usermanagement.TemplateTestPanel.java

License:Open Source License

public TemplateTestPanel(String id, final String template) {
    super(id);//w w w . j  a v a  2s  .  c  om
    Form<String> form = new Form<String>("email-form");
    final TextField<String> textField = new TextField<String>("email-field", new Model<String>(), String.class);
    form.add(textField);
    form.add(new AjaxButton("submit") {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            controller.testTemplate(textField.getModelObject(), template);
            ModalWindow modalWindow = findParent(ModalWindow.class);
            modalWindow.close(target);
        }
    });
    add(form);
}

From source file:mil.nga.giat.elasticsearch.ElasticConfigurationPanel.java

License:Open Source License

/**
 * Adds Elasticsearch configuration panel link, configure modal dialog and 
 * implements modal callback.//from www.j a  v  a  2  s  .  co  m
 * 
 * @see {@link ElasticConfigurationPage#done}
 */

public ElasticConfigurationPanel(final String panelId, final IModel model) {
    super(panelId, model);
    final FeatureTypeInfo fti = (FeatureTypeInfo) model.getObject();

    final ModalWindow modal = new ModalWindow("modal");
    modal.setInitialWidth(800);
    modal.setTitle(new ParamResourceModel("modalTitle", ElasticConfigurationPanel.this));
    modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        @Override
        public void onClose(AjaxRequestTarget target) {
            if (_layerInfo != null) {
                GeoServerApplication app = (GeoServerApplication) getApplication();
                final FeatureTypeInfo ft = (FeatureTypeInfo) getResourceInfo();

                app.getCatalog().getResourcePool().clear(ft);
                app.getCatalog().getResourcePool().clear(ft.getStore());
                setResponsePage(new ElasticResourceConfigurationPage(ft));
            }
        }
    });

    if (fti.getMetadata().get(ElasticLayerConfiguration.KEY) == null) {
        modal.add(new OpenWindowOnLoadBehavior());
    }

    modal.setContent(new ElasticConfigurationPage(panelId, model) {
        @Override
        void done(AjaxRequestTarget target, LayerInfo layerInfo, ElasticLayerConfiguration layerConfig) {
            _layerInfo = layerInfo;
            _layerConfig = layerConfig;
            modal.close(target);
        }
    });
    add(modal);

    AjaxLink findLink = new AjaxLink("edit") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            modal.show(target);
        }
    };
    final Fragment attributePanel = new Fragment("esPanel", "esPanelFragment", this);
    attributePanel.setOutputMarkupId(true);
    add(attributePanel);
    attributePanel.add(findLink);
}

From source file:net.tirasa.jpasqlazure.web.pages.EditModalPage.java

License:Apache License

public EditModalPage(final PageReference callPageRef, final ModalWindow window, final Person person,
        final PersonRepository repository) {

    feedbackPanel = new FeedbackPanel("feedback");
    feedbackPanel.setOutputMarkupId(true);
    add(feedbackPanel);//from   w  w  w.  j  a va2  s .com

    Form<Person> form = new Form<Person>("form", new CompoundPropertyModel<Person>(person));
    add(form);

    TextField username = new TextField("username");
    username.setRequired(true);
    form.add(username);

    PasswordTextField password = new PasswordTextField("password");
    password.setRequired(false);
    form.add(password);

    DropDownChoice<Gender> gender = new DropDownChoice<Gender>("gender", Arrays.asList(Gender.values()));
    gender.setRequired(true);
    form.add(gender);

    TextArea info = new TextArea("info");
    info.setRequired(false);
    form.add(info);

    IndicatingAjaxButton submit = new IndicatingAjaxButton("save") {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            try {
                repository.save(person);
                ((HomePage) callPageRef.getPage()).setModalResult(true);
                window.close(target);
            } catch (IllegalArgumentException e) {
                error("Could not save");
                target.add(feedbackPanel);
            }
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(feedbackPanel);
        }
    };
    form.add(submit);
}

From source file:nl.knaw.dans.common.wicket.components.popup.confirm.YesNoPanel.java

License:Apache License

public YesNoPanel(final ModalWindow window, String confirmMessage, final ConfirmationAnswer answer) {
    super(window.getContentId());

    Form<?> yesNoForm = new Form("yesNoForm");

    yesNoForm.add(new MultiLineLabel("confirmMessage", confirmMessage));

    AjaxSubmitLink yesButton = new AjaxSubmitLink("yesButton", yesNoForm) {
        private static final long serialVersionUID = -9006695389336829021L;

        @Override//from   w w w  . j  a v a2 s. c om
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            if (target != null) {
                answer.setAnswer(true);
                window.close(target);
            }
        }
    };

    AjaxSubmitLink noButton = new AjaxSubmitLink("noButton", yesNoForm) {
        private static final long serialVersionUID = -7737147525528570638L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            if (target != null) {
                answer.setAnswer(false);
                window.close(target);
            }
        }
    };

    yesNoForm.add(yesButton);
    yesNoForm.add(noButton);
    add(yesNoForm);
}

From source file:nl.knaw.dans.dccd.common.web.confirm.ConfirmDialogPanel.java

License:Apache License

public ConfirmDialogPanel(String id, String message, final ModalWindow modalWindow,
        final ConfirmationAnswer answer) {
    super(id);// w w  w . j av a2 s . c  om

    Form yesNoForm = new Form("yesNoForm");

    MultiLineLabel messageLabel = new MultiLineLabel("message", message);
    yesNoForm.add(messageLabel);

    initModalWindow(modalWindow);

    AjaxButton yesButton = new AjaxButton("yesButton", yesNoForm) {
        private static final long serialVersionUID = -4789365829585310382L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            if (target != null) {
                answer.setAnswer(true);
                modalWindow.close(target);
            }
        }
    };
    setButtonLabel(yesButton, "confirmDialog.yesButton.label");

    AjaxButton noButton = new AjaxButton("noButton", yesNoForm) {
        private static final long serialVersionUID = 5179369782355613213L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            if (target != null) {
                answer.setAnswer(false);
                modalWindow.close(target);
            }
        }
    };
    setButtonLabel(noButton, "confirmDialog.noButton.label");

    yesNoForm.add(yesButton);
    yesNoForm.add(noButton);

    add(yesNoForm);
}