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

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

Introduction

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

Prototype

public ModalWindow showUnloadConfirmation(final boolean unloadConfirmation) 

Source Link

Document

Sets a flag whether to ask the user before leaving the page.

Usage

From source file:com.evolveum.midpoint.web.page.admin.configuration.component.ObjectSelectionPage.java

License:Apache License

public static <T extends ObjectType> void prepareDialog(ModalWindow dialog,
        ObjectSelectionPanel.Context context, final Component callingComponent, String titleResourceKey,
        final String idToRefresh) {
    dialog.setPageCreator(new ObjectSelectionPage.PageCreator(dialog, context));
    dialog.setInitialWidth(800);// w w w.  j av  a2 s . co  m
    dialog.setInitialHeight(500);
    dialog.setTitle(PageBase.createStringResourceStatic(callingComponent, titleResourceKey));
    dialog.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
        // We are not able to refresh targets residing in the parent page
        // from inside the modal window -> so we have to do it in this
        // context, when the modal window is being closed.
        public void onClose(AjaxRequestTarget target) {
            target.add(callingComponent.get(idToRefresh));
        }
    });
    dialog.showUnloadConfirmation(false);
    dialog.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
    dialog.setCookieName(ObjectSelectionPanel.class.getSimpleName() + ((int) (Math.random() * 100)));
    dialog.setWidthUnit("px");
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.order.OrderItemPanel.java

License:Apache License

private ModalWindow addPromoCodePopup(final OrderItem parent, WebMarkupContainer membershipPlanContainer) {
    final ModalWindow popup = new ModalWindow("promoCodePopup");
    popup.setAutoSize(true);/*  ww  w .  j a  v  a 2s.  co  m*/
    popup.setResizable(false);
    popup.setMinimalWidth(500);
    popup.setWidthUnit("px");
    popup.showUnloadConfirmation(false);

    PromoCodePopupForm popupForm = new PromoCodePopupForm(popup.getContentId(),
            new Model<StringWrapper>(new StringWrapper())) {

        @Override
        protected void onSubmitAction(IModel<StringWrapper> strWrapper, AjaxRequestTarget target,
                Form<?> form) {
            String code = strWrapper.getObject().getValue();
            if (parent.getMembershipPlan() != null) {
                if (parent.getResearchGroup() == null) {
                    if (promoFacade.isValidPersonalPlanCode(code)) {
                        PromoCode promoCode = promoFacade.getPromoCodeByKeyword(code);
                        parent.setPromoCode(promoCode);
                        double price = parent.getMembershipPlan().getPrice().doubleValue()
                                * (1d - ((double) promoCode.getDiscount() / 100d));
                        parent.setPrice(new BigDecimal(price));
                    }
                } else {
                    if (promoFacade.isValidGroupPlanCode(code)) {
                        PromoCode promoCode = promoFacade.getPromoCodeByKeyword(code);
                        parent.setPromoCode(promoCode);
                        double price = parent.getMembershipPlan().getPrice().doubleValue()
                                * (1d - ((double) promoCode.getDiscount() / 100d));
                        parent.setPrice(new BigDecimal(price));
                    }
                }
            }
            ModalWindow.closeCurrent(target);
            setResponsePage(ShoppingCartPage.class);
        }

        @Override
        protected void onCancelAction(IModel<StringWrapper> strWrapper, AjaxRequestTarget target,
                Form<?> form) {
            ModalWindow.closeCurrent(target);
        }

    };
    popup.setContent(popupForm);
    membershipPlanContainer.add(popup);
    AjaxLink popupLink = new AjaxLink<Object>("applyPromoCode") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            //License l = this.getModelObject();
            //if (l!=null) System.out.println(l.getTitle());
            popup.show(target);
        }

    };
    popup.setOutputMarkupPlaceholderTag(true);
    popup.setVisibilityAllowed(true);
    String promoCode = "";
    if (parent.getPromoCode() != null) {
        promoCode = "Applied code: " + parent.getPromoCode().getKeyword() + " ("
                + parent.getPromoCode().getDiscount() + "% off)";
    }
    membershipPlanContainer.add(new Label("promoCodeText", promoCode));
    membershipPlanContainer.add(popupLink);
    popupLink.setVisible(malleable);
    return popup;
}