title: Wicket: run JavaScript when a Form is submitted
body: <p>I'm using Wicket 6.xx and I have a Wicket <code>Form</code> that I use to upload some files. This is not a problem. The problem is that I need to run some JavaScript on the page after the form has been submitted in order to show a modal popup that is JavaScript based.</p>
  
  <p>However, I can't do that because I don't have an <code>AjaxRequestTarget</code> object, since a form submission is not an Ajax call. Or at least, I'm guessing that's the reason. I've tried the following, taken from another thread, but it doesn't work:</p>
  
  <pre><code>From&lt;RequestInfo&gt; uploadFrm = new Form&lt;RequestInfo&gt;("uploadFrm", getModel()) {
      private static final long serialVersionUID = 1L;
  
      @Override
      protected void onSubmit() {
          AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);
          target.appendJavascript("..."); //NullPointerException: target is always null
      }
  };
  </code></pre>
  
  <p>As you can tell from the comment I put there, <code>target</code> is always <code>null</code>.</p>
  
  <p>What is the proper way to run some JavaScript in a situation like this? Is there a proper way?</p>