javagwtfile-uploadgwtupload

GWT fileupload, file not being sent in the POST


I am struggling with a simple file uploading using GWT 2.4 + gwtupload 0.6.4 library.

Here is the relevant part of my dialog ui.xml:

<g:DialogBox modal="true" width="400px" height="150px">
        <g:caption><ui:msg>Import new..</ui:msg></g:caption>
        <g:VerticalPanel styleName="full-width">
            <g:InlineLabel styleName="formlabel"><ui:msg>File name</ui:msg></g:InlineLabel>
            <up:Uploader ui:field="uploader" validExtensions="zip" styleName="uploader full-width">
            </up:Uploader>
            <g:Button styleName="button" ui:field="importButton" enabled="true">
                <ui:msg>Import</ui:msg>
            </g:Button>

The importButton calls uploader.submit() eventually. My problem is that the first time I press the button, and empty POST is being sent to the server and I get back an error message. If I press the button second time, my file is being POST-ed well. If I close the dialog and start over the very same thing happens. Every import attempt following the first one is OK.

Here is the empty POST example:

Content-Type: multipart/form-data;
boundary=---------------------------9003259118762
Content-Length: 46 -----------------------------9003259118762--

I tried to click a second time on the button as a workaround. However if I catch the error message received and call uploader.submit() again or call it even from a Timer() callback it is not working as when I click with the mouse the second time.

Do you have any ideas what can be wrong?


Solution

  • The solution was that some lines after uploader.submit() there was a uploader.setEnabled(false) invocation. After removing it the uploader started to work normally.. :-)