Domanda

I am using GWT to upload files to the Blobstore. I am using FormElement uploadForm that represents the <form> that is used to upload the file. After the uploadForm.submit() I need to wait on the same page and capture the callback when the file is correctly uploaded, so that I can place its path on the client code.

How can I do that? Thanks

È stato utile?

Soluzione

You just use FormPanel instead. You are very limited functions with FormElement That gives to handle many events.

 formpanel.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
      public void onSubmitComplete(SubmitCompleteEvent event) {
        // When the form submission is successfully completed, this event is
        // fired. Assuming the service returned a response of type text/html,
        // we can get the result text here (see the FormPanel documentation for
        // further explanation).
        Window.alert(event.getResults());
      }
    });

You can even capture the event just before to submit even with that

 form.addSubmitHandler(new FormPanel.SubmitHandler() {
      public void onSubmit(SubmitEvent event) {
        // This event is fired just before the form is submitted.

Update: To use FormPanel with HTML element (haven't tested)

Step 1 : get Element by Id DOM.getElementById("")

Step 2: prepare widget with it : get widget by id in gwt

Step 3: :formPanel.setWidget(thatWidget);

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top