Search code examples
file-uploadextjs4dwr

FileUploadField 'stuck' after submitting form with ExtJS4/DWR


im using extjs4 with dwr3 to upload a file

this is all i have in my form

{xtype: 'fileuploadfield',
name: 'file',
fieldLabel: 'Archivo', 
allowBlank: false,
buttonText: 'Seleccionar...' 
}, {
xtype: 'button',
text: 'Cargar',
action: 'cargarArchivo'
}

when i click the button (labeled Cargar) it submits the file and stays in the same page, so far so good. Problem is, when i choose another file, the text in the field stays the same instead of showing the new file chosen

this is what i have in my controller:

init: function() {
    this.control({
        'NciImport button[action=cargarArchivo]': {
            click: this.cargaArchivo
        } 
    });
},

cargaArchivo : function (button){
    clickedButton = button;
    bsNciNiv.cargaArchivoNci(dwr.util.getValue('file'), function(x,y,z){
        clickedButton.up('form').down('fileuploadfield').createFileInput(); // funny solution
    });
}

The bsNciNiv.cargaArchivoNci part is my DWR service

the line i commented as funny solution kind of works, after adding it the rest works as expected, but i really dont think it is the right solution, just added it as a hint in case its useful

can anyone confirm if this is a bug or if theres a way to fix this? thanks

(btw not sure if this has anything to do with dwr3, but i tagged it anyway)


Solution

  • My guess is that this component was not designed to upload multiple files (in series). The issue you are seeing is probably due to this hidden element not getting cleared: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.field.File-property-fileInputEl

    You can probably file this as a bug with Sencha although they might consider it a feature :)