PDA

View Full Version : Wait for response by BaseicForm standardSubmit = true



JJDoneAway
19 Jul 2010, 9:01 AM
Hello

I implement a file download at the moment. The server will take some minutes until the file is sent to the client. As I'll do a file download I set standardSubmit to true. Now I got the problem that I'm not able to block the GUI until the server sends the file back. But if I don't block the GUI the user is able to click around. So the user looses the connection to the server and won't get it's file.

Here is my code:


var excelFormForm = new Ext.form.FormPanel(
{
id : 'excelFormForm',
baseCls : 'x-plain',
labelWidth : 55,
standardSubmit : true,
// no url as we use standard submission
items : [
{
xtype : 'label',
html : '<div style="margin-bottom:10pt; font-size:13px; ">'+jsMessageResource.getMessage('excel.report.select.language.msg')+'</div>',
anchor : '100%'
}, {
xtype : "languagesComboBox",
displayField : 'key',
fieldLabel : jsMessageResource.getMessage('excel.report.select.language'),
name : 'excelLanguage',
allowBlank : false,
editable : false,
autoScroll : true,
anchor : '100%'
}, {
xtype : 'label',
id : 'excelWarnTxt',
html : warnTxt,
anchor : '100%'
}, {
xtype : 'hidden',
id : 'excelQueryConfig',
name : 'queryConfig',
value : Ext.util.JSON.encode(this.queryCfg),
anchor : '100%'
}, {
xtype : 'hidden',
id : 'excelCountTotal',
name : 'countTotal',
value : totalSize,
anchor : '100%'
} ]
});

var excelForm = new Ext.Window(
{
id : 'excelFormWindow',
renderTo : document.body,
title : titleTxt,
width : 400,
minWidth : 150,
minHeight : 150,
layout : 'fit',
plain : true,
modal : true,
bodyStyle : 'padding:5px',
buttonAlign : 'center',
closable : false,
items : excelFormForm,

buttons : [
{
id : 'excelOk',
text : 'OK',
handler : function() {
excelFormForm.getForm().getEl().dom.action = GLOBAL_DYNAMIC_VARS.CURRENTCONTEXTPATH + '/main/reporting/detailReport.xls';
excelFormForm.getForm().submit();

//here I want to wait until the server send me my file

excelForm.close();
}
}, {
id : 'excelCancel',
text : 'Cancel',
handler : function() {
excelForm.close();
}
} ]
});
}

JJDoneAway
19 Jul 2010, 9:28 AM
Ok, i found a convenient solution:



excelFormForm.getForm().getEl().dom.target = '_blank';


This will open a new tab or window in your browser and you can continue working with your application