martin-g commented on a change in pull request #361: WICKET-6666 initial
checkin of new ModalDialog
URL: https://github.com/apache/wicket/pull/361#discussion_r283631302
##########
File path:
wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/ModalDialog.java
##########
@@ -0,0 +1,240 @@
+package org.apache.wicket.extensions.ajax.markup.html.modal;
+
+import java.io.Serializable;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.JavaScriptHeaderItem;
+import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.panel.EmptyPanel;
+import org.apache.wicket.markup.html.panel.Panel;
+
+import com.github.openjson.JSONStringer;
+
+/**
+ * Presents a modal dialog to the user. See open and close methods.
+ *
+ * @author Igor Vaynberg (ivaynberg)
+ */
+public class ModalDialog extends Panel
+{
+
+ public static final String CONTENT_ID = "content";
+
+ private final WebMarkupContainer container;
+ private final WebMarkupContainer contentContainer;
+ private boolean open = false;
+ private transient boolean openedInThisRequest = false;
+ private Options options;
+
+ public ModalDialog(String id)
+ {
+ super(id);
+ setOutputMarkupId(true);
+
+ // Container controls the overall visibility of the modal form
innards. In its initial state
+ // this is set to
+ // hidden so only the external tag renders. When the modal is
openedInThisRequest it is
+ // first repainted with
+ // this shown to
+ // insert the markup into the dom, and then the modal
javascript is invoked to rip out this
+ // tag out of the dom
+ // and make it modal.
+ container = new WebMarkupContainer("container");
+ container.setOutputMarkupId(true);
+ container.setVisible(false);
+ add(container);
+
+ // We need this here in case the modal itself is placed inside
a form. If that is the case
+ // and the content
+ // contains a form that form's markup form tag will be rendered
as div because as far as
+ // wicket is concerned it
+ // is part of the same dom as the page and nested forms are
forbidden. By overriding
+ // isRootForm() to true we are
+ // forcing this form - which will be ripped out of the dom
along with the content form if
+ // there is one to always
+ // render its tag as 'form' instead of 'div'.
+ var form = new Form<Void>("form")
Review comment:
:champagne: I believe this is the first usage of `var` in Wicket ! :-)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services