title: Wrapping/decorating GWT FileUpload
body: <p>GWT FileUpload comes as a widget that produces  so that one can upload a file during form submit (at least it's how I understand it :) ) What I want to do is to make it a better-looking and get rid of standard "Browse..." button. </p>
  
  <p>Since I don't have good GWT experience (and no JavaScript), I looked for existing solutions and found quite a good project - <a href="http://code.google.com/p/gwtupload/" rel="nofollow">gwtupload</a>. It's good, but I realized I'd love to have my own miniature version (and also, I was curious about how it works). So I browsed through code and tried to extract the magic part. I realized that GWT FileInput is used, but it's not shown, and Button clicks are delegated to this FileInput. The code I tried to extract (only the part that delegates the click) after reviewing sources of <a href="http://code.google.com/p/gwtupload/" rel="nofollow">gwtupload</a> contains this tricky <code>elem.click()</code> JSNI:</p>
  
  <pre><code>class MyUpload extends Composite {
      private static native void clickOnInputFile(Element elem) /*-{
          elem.click();
      }-*/;
  
      public MyUpload() {
          final FileUpload upload = new FileUpload();
          AbsolutePanel container = new AbsolutePanel();
          // container.add(upload);
          Button btn = new Button("My Browse..");
          btn.addClickHandler(new ClickHandler() {
              @Override
              public void onClick(ClickEvent event) {
                  clickOnInputFile(upload.getElement());
              }
          });
          container.add(btn);
          initWidget(container);
      }
  }
  </code></pre>
  
  <p>But this seems not to work: clicking on 'My Browse..' results in no effect (just in case I also tried running with un-commented <code>container.add(upload)</code> line) . Could you please help me in understanding what's wrong/missing in this code sample?</p>
  
  <p>Thank you in advance.</p>
  
  <p>P.S. I know that I have to place it on the FormPanel, and I know the rest about how to perform the actual submit/handling in Servlet; the only thing I want to do is this kind of decoration.</p>