Hi All,
I'm using ExtDirect in my Application and all worked perfectly except form upload with multipart data.
In fact, the program can't reach method in server (trying to debug) when submitting the form. Any error is raised in browser console and Response code is 200 (OK).
Could you please advise ?
Here is my code:
Code:
{
xtype: 'form',
border: false,
hidden: true,
itemId: 'ReportTemplateEditingForm',
layout: 'fit',
header: false,
fileUpload: true,
title: '${menu.admin.reporttemplate}',
items: [
{
xtype: 'fieldset',
itemId: 'setGeneral',
defaults: {
labelWidth: 300,
labelStyle: 'font-size: 11px; font-weight: bold;',
fieldStyle: 'font-size: 11px;',
anchor: '100%'
},
collapsible: true,
items: [
{
xtype: 'textfield',
itemId: 'templateDescription',
fieldLabel: 'Template Description',
name: 'templateDescription',
allowBlank: true,
enforceMaxLength: true,
maxLength: 255
},
{
xtype: 'filefield',
name: 'templateFile',
buttonOnly: false,
fieldLabel: 'Template File',
msgTarget: 'side',
allowBlank: false,
buttonText: 'Select Template...'
}
]
}
],
api: {
submit: reportTemplateAction.uploadTemplate
},
dockedItems: [
{
xtype: 'editingtoolbar',
save: function(button) {
var me = button,
tb = me.up('editingtoolbar'),
form = me.up('form').getForm();
form.submit({
waitMsg: 'Uploading your files...',
success: function(form, action) {
//textArea1.setValue(action.result.fileContents);
console.log('File uploaded !');
}
});
},
editJurisdiction: [
'jur_folder_update'
],
dock: 'bottom'
}
]
}
- Direct REMOTING_API (api.js)
Code:
Ext.ns('Ext.app');Ext.app.REMOTING_API = {"url":"...","type":"remoting","actions":{"reportTemplateAction":[{"name":"findReportTemplate","len":1},{"name":"read","len":1},{"name":"downloadReportTemplate","params":["templateId"]},{"name":"save","len":1},{"name":"uploadTemplate","len":0,"formHandler":true}], .....},"timeout":60000};
Code:
@ExtDirectMethod(ExtDirectMethodType.FORM_POST)
public ExtDirectFormPostResult uploadTemplate(HttpSession session,
@RequestParam(value = "templateFile", required = true) MultipartFile templateFile,
@RequestParam(value = "templateDescription", required = false) String templateDescription) {
ExtDirectFormPostResult response = new ExtDirectFormPostResult(true);
// file will be process here
// ...
return response;
}