title: Close wicket modal window by pressing a button
body: <p>I want to close a modal window by pressing a button residing on the modal window page. It is not working. My modal window page contains a video player.</p>
  
  <p>My code is:</p>
  
  <pre><code>public class PlayVideoWindow extends WebPage {
      public PlayVideoWindow(final Page modalWindowPage, final ModalWindow window, final String itemId) {
          final String xmlFilePath = ((WebApplication) getApplication()).getServletContext().getRealPath("/resources/video/xml/video.xml");
          String filename = null; 
  
          try {
              filename = WebVideo.getVideo(itemId, xmlFilePath);
          } catch (SAXException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }        
  
          WebMarkupContainer videoContainer = new WebMarkupContainer("videoDiv");
          add(videoContainer);
  
          add(HeaderContributor.forJavaScript("resources/video/js/swfobject.js"));
  
          final String script = "var swfVersionStr = '10.0.0';"
              + "var xiSwfUrlStr = 'playerProductInstall.swf';"
              + "var flashvars = {};"
              + "flashvars.filename = '"+ filename +"'" +";"
              + "var params = {};"
              + "params.wmode = 'transparent';"
              + "params.quality = 'high';"
              + "params.allowscriptaccess = 'always';"
              + "params.allowfullscreen = 'true';"
              + "params.allownetworking = 'all';"
              + "var attributes = {};"
              + "attributes.id = 'Player';"
              + "attributes.name = 'Player';"
              + "attributes.align = 'left';"
              + "swfobject.embedSWF('/jtrac/resources/video/swf/Player.swf', 'movieDiv', '320', '320', swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);"
              + "swfobject.createCSS('#flashContent', 'display:block;text-align:left;');";
  
      add(new AbstractBehavior() {
          public void renderHead(IHeaderResponse response) {
              super.renderHead(response);
              response.renderOnLoadJavascript(script);
          }
      });
  
      //videoContainer.add(new AjaxButton("close") {
        //  protected void onSubmit(final AjaxRequestTarget target, final Form form) {
          //    PlayVideoWindow.this.close(target);
          //}
      //});
  
      //Button closeButton;
      //videoContainer.add(closeButton = new Button("close"));
      //closeButton.add(new AttributeAppender("onclick", new Model("window.close();"), ";"));
      }
  }
  </code></pre>
  
  <p>And here's the HTML:</p>
  
  <pre><code>&lt;div wicket:id="videoDiv"&gt;
  &lt;div id="movieDiv"&gt;&lt;/div&gt;
  &lt;input type="button" wicket:id="close" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The commented-out lines of code are my tests. Any information will be very helpful to me. Thank you.</p>
  
  <p>EDIT:<br>
  I solved my problem with this code:</p>
  
  <pre><code>add(new AjaxLink("close") {
          public void onClick(AjaxRequestTarget target) {
              window.close(target);
          }
      });
  </code></pre>