3
* Copyright(c) 2006-2008, Ext JS, LLC.
6
* http://extjs.com/license
10
* @class Ext.data.HttpProxy
11
* @extends Ext.data.DataProxy
12
* An implementation of {@link Ext.data.DataProxy} that reads a data object from a {@link Ext.data.Connection Connection} object
13
* configured to reference a certain URL.<br>
15
* <b>Note that this class cannot be used to retrieve data from a domain other than the domain
16
* from which the running page was served.<br>
18
* For cross-domain access to remote data, use a {@link Ext.data.ScriptTagProxy ScriptTagProxy}.</b><br>
20
* Be aware that to enable the browser to parse an XML document, the server must set
21
* the Content-Type header in the HTTP response to "text/xml".
23
* @param {Object} conn an {@link Ext.data.Connection} object, or options parameter to {@link Ext.Ajax#request}.
24
* If an options parameter is passed, the singleton {@link Ext.Ajax} object will be used to make the request.
26
Ext.data.HttpProxy = function(conn){
27
Ext.data.HttpProxy.superclass.constructor.call(this);
29
* The Connection object (Or options parameter to {@link Ext.Ajax#request}) which this HttpProxy uses to make requests to the server.
30
* Properties of this object may be changed dynamically to change the way data is requested.
34
this.useAjax = !conn || !conn.events;
37
* @event loadexception
38
* Fires if an exception occurs in the Proxy during data loading. This event can be fired for one of two reasons:
39
* <ul><li><b>The load call returned success: false.</b> This means the server logic returned a failure
40
* status and there is no data to read. In this case, this event will be raised and the
41
* fourth parameter (read error) will be null.</li>
42
* <li><b>The load succeeded but the reader could not read the response.</b> This means the server returned
43
* data, but the configured Reader threw an error while reading the data. In this case, this event will be
44
* raised and the caught error will be passed along as the fourth parameter of this event.</li></ul>
45
* Note that this event is also relayed through {@link Ext.data.Store}, so you can listen for it directly
46
* on any Store instance.
47
* @param {Object} this
48
* @param {Object} options The loading options that were specified (see {@link #load} for details)
49
* @param {Object} response The XMLHttpRequest object containing the response data
50
* @param {Error} e The JavaScript Error object caught if the configured Reader could not read the data.
51
* If the load call returned success: false, this parameter will be null.
55
Ext.extend(Ext.data.HttpProxy, Ext.data.DataProxy, {
57
* Return the {@link Ext.data.Connection} object being used by this Proxy.
58
* @return {Connection} The Connection object. This object may be used to subscribe to events on
59
* a finer-grained basis than the DataProxy events.
61
getConnection : function(){
62
return this.useAjax ? Ext.Ajax : this.conn;
66
* Load data from the configured {@link Ext.data.Connection}, read the data object into
67
* a block of Ext.data.Records using the passed {@link Ext.data.DataReader} implementation, and
68
* process that block using the passed callback.
69
* @param {Object} params An object containing properties which are to be used as HTTP parameters
70
* for the request to the remote server.
71
* @param {Ext.data.DataReader} reader The Reader object which converts the data
72
* object into a block of Ext.data.Records.
73
* @param {Function} callback The function into which to pass the block of Ext.data.Records.
74
* The function must be passed <ul>
75
* <li>The Record block object</li>
76
* <li>The "arg" argument from the load function</li>
77
* <li>A boolean success indicator</li>
79
* @param {Object} scope The scope in which to call the callback
80
* @param {Object} arg An optional argument which is passed to the callback as its second parameter.
82
load : function(params, reader, callback, scope, arg){
83
if(this.fireEvent("beforeload", this, params) !== false){
85
params : params || {},
92
callback : this.loadResponse,
96
Ext.applyIf(o, this.conn);
97
if(this.activeRequest){
98
Ext.Ajax.abort(this.activeRequest);
100
this.activeRequest = Ext.Ajax.request(o);
102
this.conn.request(o);
105
callback.call(scope||this, null, arg, false);
110
loadResponse : function(o, success, response){
111
delete this.activeRequest;
113
this.fireEvent("loadexception", this, o, response);
114
o.request.callback.call(o.request.scope, null, o.request.arg, false);
119
result = o.reader.read(response);
121
this.fireEvent("loadexception", this, o, response, e);
122
o.request.callback.call(o.request.scope, null, o.request.arg, false);
125
this.fireEvent("load", this, o, o.request.arg);
126
o.request.callback.call(o.request.scope, result, o.request.arg, true);
130
update : function(dataSet){
135
updateResponse : function(dataSet){
b'\\ No newline at end of file'