PDA

View Full Version : Ext Form submit run forever



yugikhoi
27 Aug 2010, 10:16 PM
Hi,

I do a form and try to submit it however it running forever and never end. So how to let ext form know that my form has submit successful. Below is my code


var submitHandler = function() {
var formPanel = Ext.getCmp('addCustomerWindowCardLayout');
formPanel.el.mask('Please wait', 'x-mask-loading');

formPanel.getForm().submit({
url: 'test.jsp',
method:'POST',
success: function(){
//Ext.Msg.alert('Success', 'It worked');
Ext.getCmp('filenotes').setStatus({
text: 'Login success !',
iconCls: 'x-status-valid'
});
},
failure: function(f,a){
if (a.failureType === Ext.form.Action.CONNECT_FAILURE){
Ext.Msg.alert('Failure', 'Server reported:'+a.response.status+' '+a.response.statusText);
}
if (a.failureType === Ext.form.Action.SERVER_INVALID){
Ext.Msg.alert('Warning', a.result.errormsg);
}
}
});
}

Animal
27 Aug 2010, 11:16 PM
Well it's obviously a failure of another type, isn't it?

Ash2009
31 Aug 2010, 7:42 PM
Thats a issue I am facing too,
somehow there is a connection fault in between and ExtJs is not able to sense that failure.my loading wheel keeps spinning.
How do we handle cases which dont fall into success or known failure cases.
is there any solution to this ?

Animal
31 Aug 2010, 9:24 PM
How are you debugging?

Ash2009
1 Sep 2010, 8:16 AM
How are you debugging?

I did not understand your question.But i use firebug for debugging.

Animal
1 Sep 2010, 9:44 AM
Debugging as i stepping through code.

Ash2009
1 Sep 2010, 11:02 AM
stepping through code doesnt help ,coz after submit the call backs (success or failure)never gets called.since ExtJs is not able to detect the failure somehow.The question here is
Can ExtJs detect browsers submit failures ?

Ash2009
1 Sep 2010, 11:05 AM
failure in this case occurs before the server is reached.so there is no question of success:true or false coming back.

Animal
1 Sep 2010, 11:48 AM
Using ext-all-debug.js, find the Submit Action's run method ad set a breakpoint in it:



Ext.extend(Ext.form.Action.Submit, Ext.form.Action, {

...

// private
run : function(){
var o = this.options,
method = this.getMethod(),
isGet = method == 'GET';
if(o.clientValidation === false || this.form.isValid()){
if (o.submitEmptyText === false) {
var fields = this.form.items,
emptyFields = [],
setupEmptyFields = function(f){
if (f.el.getValue() == f.emptyText) {
emptyFields.push(f);
f.el.dom.value = "";
}
if(f.isComposite && f.rendered){
f.items.each(setupEmptyFields);
}
};

fields.each(setupEmptyFields);
}
Ext.Ajax.request(Ext.apply(this.createCallback(o), {
form:this.form.el.dom,
url:this.getUrl(isGet),
method: method,
headers: o.headers,
params:!isGet ? this.getParams() : null,
isUpload: this.form.fileUpload
}));
if (o.submitEmptyText === false) {
Ext.each(emptyFields, function(f) {
if (f.applyEmptyText) {
f.applyEmptyText();
}
});
}
}else if (o.clientValidation !== false){ // client validation failed
this.failureType = Ext.form.Action.CLIENT_INVALID;
this.form.afterAction(this, false);
}
},

yugikhoi
1 Sep 2010, 5:36 PM
I find the problem of my case, it is because of the context_path so that it cannot find the URL of submit file. The solution is just refine the URL with context_path content or add a file mapping to web.xml in WEB_INF.

Thanks all for help.