Jag
Jag

Reputation: 89

GWT FileUpload - Set the response Content-Type through Client code

I have a file upload form in GWT and the upload process works fine. Though, I have problem getting the response. The response capturing code is:

formUpload.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
    @Override
    public void onSubmitComplete(final SubmitCompleteEvent event) {
        fileUploadControl.handleResponse(htmlToText(event.getResults()));
    }
});

The event.getResults() always results in null. Upon investigating, I found that the response Content-Type should be one of text/html or text/plain. In my case, it is application/xml and I can't control the server response as well.

I was wondering if it is possible to set Accept request header in file upload form. If it is not possible, any other suggestion is appreciated.

Upvotes: 1

Views: 950

Answers (1)

Jama A.
Jama A.

Reputation: 16099

See documentation SubmitCompleteEvent#getResults

public java.lang.String getResults() Gets the result text of the form submission.
Returns:
the result html, or null if there was an error reading it
Tip:
The result html can be null as a result of submitting a form to a different domain.

If It is working without errors, maybe domains are different.

Upvotes: 0

Related Questions