PDA

View Full Version : actioncomplete is not triggred on Ext.form.Panel's successfull Standardsubmit request



ashu2289
31 May 2012, 1:31 AM
Hi folks,

I am trying to mask the screen while form submit response is received from the server.
On success/ failure of the response, i will be hiding the screen mask.
I am able to mask the screen before submitting the form submit request but when to hide it,
actioncomplete or actionfailure events are not triggered, although before action works just fine.

Need serious help.

Here is the sample Code:

onExportToPdf:function () {
var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});

var form = Ext.create('Ext.form.Panel', {
url:this.contextPath + '/export/' + this.mode + '/xyz.pdf',
method:'POST',
standardSubmit:true,
hidden:true,
renderTo:Ext.getBody(),
listeners:{
beforeaction: function(form, action){
myMask.show();
},
actioncomplete: function(form, action){
myMask.hide();
},
actionfailed: function(form, action){
myMask.hide();
}
}
});


form.getForm().submit({
target:'_self',
params:{criteria: this.criteria,
status:nodes}
});
Ext.removeNode(form);
}

sword-it
31 May 2012, 4:33 AM
Hi ashu2289,

Try this one it work fine for me




var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});

var form = Ext.create('Ext.form.Panel', {
items: [{
xtype: 'textfield',
fieldLabel: 'file',
name: 'photo-path',
}],
buttons: [{
text: 'Save',
handler: function() {
myMask.show();
form.getForm().submit({
url: '/echo/json/',
success: function(fp, o) {
myMask.hide();
Ext.Msg.alert('Sucessfully', 'Sucessfully done');
},
failure: function(form, action) {
myMask.hide();
Ext.Msg.alert('cccc', 'ddd');
}
});

}}]
});
Ext.create('Ext.Window', {
title: 'Upload a file',
width: 400,
modal: true,
height: 200,
plain: true,
layout: 'fit',
items: [form]
}).show();

ashu2289
2 Jun 2012, 1:51 AM
Yeah, it works fine. but it does not solve my query or my purpose.
Lets me give you a brief:
1)I have a button("Export to PDF"), on clicking on this button above mentioned handler/ function is invoked.
2) There is a span of time between request been made to server and response recieved from server in the form of PDF ready to download.
3) I want a mask screen to appear on HTML body in this mean time.
4) Before submitting the form request i enable the mask screen.

The query is how will i get to know that the response is received and now i can hide the mask screen.
There should be an event like "actioncomplete/success" being triggered on receipt of response. I am not getting it working for me.

YASS_DEV
22 Jun 2012, 12:35 AM
Hi Ashu,

I have exactly the same problem... Have you found any solution to do it right?

ashu2289
22 Jun 2012, 10:36 PM
Infact, this event will not be triggered if we make standardSubmit set to true.
On standardSubmit of a form, a complete new view is demanded from server, in my case it was an attachment.
So browser automatically reads the content type and makes it downloadable bcz of which current view is not replaced.
There is no way that a new page before rendering should acknowledge the previous page and thats what I was
Trying to do here.
I resolved this issue using cookie, I sent a cookie in the response from server.
And using Extjs timer I am monitoring when does the cookie gets set and thus accordingly turn off
The mask window.

Does it help you????