vmorale4
30 Mar 2008, 5:18 PM
Hi,
It would be great if the Action.Submit class could accept a headers config option.
This would be very helpful when performing custom authentication/validation. For example in our application we use a custom header with an authentication token that the server analyzes. It could also be useful to help solve some content encoding issues that others (http://extjs.com/forum/showthread.php?p=88788#post88788) have encountered, but personally I haven't experimented with the latter.
I studied the source code, and internally Action uses Ajax.request --which supports custom headers--, so it is just that the Action class is not exposing this functionality. Adding this feature would be trivial (two lines). Below is the patch that I'm currently using for our web application
Ext.override(Ext.form.Action.Submit, {
run : function(){
var o = this.options;
var method = this.getMethod();
var headers = o.headers; //Added by vmorale4
var isGet = method == 'GET';
if(o.clientValidation === false || this.form.isValid()){
Ext.Ajax.request(Ext.apply(this.createCallback(o), {
form:this.form.el.dom,
url:this.getUrl(isGet),
method: method,
headers:headers, //Added by vmorale4
params:!isGet ? this.getParams() : null,
isUpload: this.form.fileUpload
}));
}else if (o.clientValidation !== false){ // client validation failed
this.failureType = Ext.form.Action.CLIENT_INVALID;
this.form.afterAction(this, false);
}
}
});
Please consider including this in the next release.
Thanks!
Victor
It would be great if the Action.Submit class could accept a headers config option.
This would be very helpful when performing custom authentication/validation. For example in our application we use a custom header with an authentication token that the server analyzes. It could also be useful to help solve some content encoding issues that others (http://extjs.com/forum/showthread.php?p=88788#post88788) have encountered, but personally I haven't experimented with the latter.
I studied the source code, and internally Action uses Ajax.request --which supports custom headers--, so it is just that the Action class is not exposing this functionality. Adding this feature would be trivial (two lines). Below is the patch that I'm currently using for our web application
Ext.override(Ext.form.Action.Submit, {
run : function(){
var o = this.options;
var method = this.getMethod();
var headers = o.headers; //Added by vmorale4
var isGet = method == 'GET';
if(o.clientValidation === false || this.form.isValid()){
Ext.Ajax.request(Ext.apply(this.createCallback(o), {
form:this.form.el.dom,
url:this.getUrl(isGet),
method: method,
headers:headers, //Added by vmorale4
params:!isGet ? this.getParams() : null,
isUpload: this.form.fileUpload
}));
}else if (o.clientValidation !== false){ // client validation failed
this.failureType = Ext.form.Action.CLIENT_INVALID;
this.form.afterAction(this, false);
}
}
});
Please consider including this in the next release.
Thanks!
Victor