/** * Sets whether the close handler is used or not. Default is false. * * @param useCloseHandler True if close handler should be used * @return This */ public final Modal<T> useCloseHandler(final boolean useCloseHandler) { if (useCloseHandler) { if (closeBehavior == null) { closeBehavior = new IndicatorModalCloseBehavior() { private static final long serialVersionUID = -4955472558917915340L; @Override protected void onEvent(final AjaxRequestTarget target) { if (isVisible()) { onClose(target); appendCloseDialogJavaScript(target); } } }; add(closeBehavior); } } else if (closeBehavior != null) { remove(closeBehavior); closeBehavior = null; } return this; }
public BaseModal(final String id) { super(id); form = new Form<>(FORM); form.setOutputMarkupId(true); add(form); content = new AbstractModalPanel<T>(this, null) { private static final long serialVersionUID = 1L; }; content.setOutputMarkupId(true); form.add(content); useCloseHandler(true); this.windowClosedCallback = null; components = new ArrayList<>(); // Note: not adding this would imply adding WebjarsJavaScriptResourceReference about JQuery resizable and mouse // add(new Resizable().withChildSelector(".modal-content")); // Note: not adding this would imply adding of WebjarsJavaScriptResourceReference about JQuery draggable add(new Draggable(new DraggableConfig().withHandle(".modal-header").withCursor("move"))); defaultModalCloseButton = new DefaultModalCloseButton(); addButton(defaultModalCloseButton); setUseKeyboard(true); setFadeIn(true); }