1 /**
  2  * Abstract Base for all classes which simulate the xhr level2 object
  3  * with a different transport
  4  *
  5  * <h3>Every class inheriting the interface must expose following methods and attributes</h3>
  6  *
  7  * <ul>
  8  *      <li>open(method, url, async)</li>
  9  *      <li>send(formData)</li>
 10  *      <li>setRequestHeader(key, value)</li>
 11  *      <li>abort()</li>
 12  *      <li>onloadstart()</li>
 13  *      <li>onprogress()</li>
 14  *      <li>onabort()</li>
 15  *      <li>onerror()</li>
 16  *      <li>onload()</li>
 17  *      <li>ontimeout()</li>
 18  *      <li>onloadend()</li>
 19  *      <li>onreadystatechange()</li>
 20  * </ul>
 21  * <h3>following attributes are supported</h3>
 22  * <ul>
 23  *      <li>async</li>
 24  *      <li>url</li>
 25  *      <li>method</li>
 26  *      <li>timeout</li>
 27  *      <li>response</li>
 28  *      <li>responseText</li>
 29  *      <li>responseXML</li>
 30  *      <li>status</li>
 31  *      <li>statusText</li>
 32  * </ul>
 33  */
 34 /**
 35  * @class
 36  * @name BaseRequest
 37  * @memberOf myfaces._impl.xhrCore.engine
 38  * @extends myfaces._impl.core.Object
 39  * @description
 40  * Abstract Base for all classes which simulate the xhr level2 object
 41  * with a different transport
 42  *
 43  * <h3>Every class inheriting the interface must expose following methods and attributes</h3>
 44  *
 45  * <ul>
 46  *      <li>open(method, url, async)</li>
 47  *      <li>send(formData)</li>
 48  *      <li>setRequestHeader(key, value)</li>
 49  *      <li>abort()</li>
 50  *      <li>onloadstart()</li>
 51  *      <li>onprogress()</li>
 52  *      <li>onabort()</li>
 53  *      <li>onerror()</li>
 54  *      <li>onload()</li>
 55  *      <li>ontimeout()</li>
 56  *      <li>onloadend()</li>
 57  *      <li>onreadystatechange()</li>
 58  * </ul>
 59  * <h3>following attributes are supported</h3>
 60  * <ul>
 61  *      <li>async</li>
 62  *      <li>url</li>
 63  *      <li>method</li>
 64  *      <li>timeout</li>
 65  *      <li>response</li>
 66  *      <li>responseText</li>
 67  *      <li>responseXML</li>
 68  *      <li>status</li>
 69  *      <li>statusText</li>
 70  * </ul>
 71  */
 72 _MF_CLS(_PFX_XHR+"engine.BaseRequest", _MF_OBJECT,
 73         /** @lends myfaces._impl.xhrCore.engine.BaseRequest.prototype */
 74         {
 75             /*standard attributes*/
 76 
 77             /**
 78              * timeout attribute with a timeout for the request in miliseconds
 79              */
 80             timeout: 0,
 81             /**
 82              * readonly ready stte attribute
 83              */
 84             readyState: 0,
 85             /**
 86              * send method, allowed values POST and GET
 87              */
 88             method: "POST",
 89             /**
 90              * the url for the call
 91              */
 92             url:null,
 93             /**
 94              * asynchronous request, if set to true then the request happens
 95              * asynchronously, if possible.
 96              */
 97             async:true,
 98             /**
 99              * read only response object, containing the response as json/dom representation
100              */
101             response: null,
102             /**
103              * read only plain text representation of the response
104              */
105             responseText: null,
106             /**
107              * xml dom readonly representation of the response
108              */
109             responseXML: null,
110             /**
111              * readonly status code of the response
112              */
113             status: null,
114             /**
115              * readonly status text of the response
116              */
117             statusText: null,
118 
119             constructor_: function(params) {
120                 this._callSuper("constructor_", params);
121                 this._initDefaultFinalizableFields();
122 
123                 this._XHRConst = myfaces._impl.xhrCore.engine.XhrConst;
124                 this._Lang.applyArgs(this, params);
125             },
126 
127             //open send, abort etc... abstract
128             /**
129              * opens the transport element
130              * @param {String} method transport method allowed values <i>POST</i> and <i>GET</i>
131              * @param {String} url optional url
132              * @param {Boolean} async optional param asynchronous transmission if set to true
133              */
134             open: function(method, url, async) {
135                 this._implementThis();
136             },
137             /**
138              * send method
139              * @param {Object} formData data to be posted within the request
140              */
141             send: function(formData) {
142                 this._implementThis();
143             },
144             /**
145              * appends a key value pair to the request header if possible
146              * @param {String} key the key of the request header entry
147              * @param {String} value  the value for the key
148              */
149             setRequestHeader: function(key, value) {
150                 this._implementThis();
151             },
152             /**
153              * aborts the transmission
154              */
155             abort: function() {
156                 this._implementThis();
157             },
158 
159             //empty implementations for the callback handlers
160             /**
161              * callback once the transmission has started
162              * @param evt
163              */
164             onloadstart: function(evt) {
165             },
166             onprogress: function(evt) {
167             },
168             onabort: function(evt) {
169             },
170             onerror: function(evt) {
171             },
172             onload: function(evt) {
173             },
174             ontimeout: function(evt) {
175             },
176             onloadend: function(evt) {
177             },
178             onreadystatechange: function(evt) {
179             },
180 
181             _implementThis: function() {
182                 throw Error("the function needs to be implemented");
183             }
184         });