示例#1
0
  /**
   * Initialize widget components and layout elements.
   *
   * @param type file input to use
   * @param form An existing form panel to use
   */
  public Uploader(FileInputType type, FormPanel form) {
    thisInstance = this;
    this.fileInputType = type;

    if (form == null) {
      form = new FormFlowPanel();
    }
    uploadForm = form;
    uploadForm.setEncoding(FormPanel.ENCODING_MULTIPART);
    uploadForm.setMethod(FormPanel.METHOD_POST);
    uploadForm.addSubmitHandler(onSubmitFormHandler);
    uploadForm.addSubmitCompleteHandler(onSubmitCompleteHandler);
    // Issue #206
    FormElement.as(uploadForm.getElement()).setAcceptCharset("UTF-8");

    uploaderPanel = getUploaderPanel();
    uploaderPanel.add(uploadForm);
    uploaderPanel.setStyleName(STYLE_MAIN);

    setFileInput(fileInputType.getInstance());

    setStatusWidget(statusWidget);

    super.initWidget(uploaderPanel);
  }