Tangled for a long time, finally realized the ExtJS download function, in fact, the principle of downloading is very simple, is to give the interface a button, let the button trigger the background action, the address back to the foreground. The specific implementation is as follows.
//extjs Code, page
var btn_out_user = new Ext.button ({ text: ' Export Excel ', Iconcls: ' Icon-del ', Handler: function() { Ext.MSG.Show({ title:' Confirm export ', msg: ' Are you sure you exported the data? ', Buttons: Ext.MSG.YESNO, width: -, fn: function(btn){ if(btn==' yes '){ Ext.MessageBox.wait(' exporting data, please wait ... ', ' Tips '); Ext.Ajax.Request({ URL: ' Outshopinfoaction.action ', Success: function(resp,Ops){ varobj= Ext.Decode(resp.ResponseText); window.Parent.Document. Location=obj.Path;//Assign a value to the address Ext.MessageBox.UpdateProgress(1); //Set progress bar Ext.MessageBox.Hide(); //Close progress bar Ds_user.Load({params : {Start: 0,Limit: -}}); }, Failure: function() { Ext.MessageBox.UpdateProgress(1); Ext.MessageBox.Hide(); Ext.MSG.Show({ title: ' ERROR hints ', msg: ' An error occurred while deleting! ', width: $, Buttons: Ext.MSG.OK, icon: Ext.MSG.ERROR }); } }); } }, icon: Ext.MessageBox.QUESTION }); } });
The background calling program is as follows:
public voidout ()throws Exception {String = ".. /upload/test.xls "; this. GetResponse (). getwriter (). Write ("{' Path ': '"+outpath+"'}"); }
Here the request is to use JSON data passing, in the daemon, pass a parameter path, its value is: String Outpath = ". /upload/test.xls ". The foreground is responsible for receiving this parameter, and the value of this parameter is obtained by the parameter name.
var=Ext. Decode (resp. ResponseText ); window . Parent . Document . = obj. Path ;
Through the above method, you can give the foreground push value in the background.