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, /** @lends myfaces._impl.xhrCore.engine.BaseRequest.prototype */ { 73 /*standard attributes*/ 74 75 /** 76 * timeout attribute with a timeout for the request in miliseconds 77 */ 78 timeout:0, 79 /** 80 * readonly ready stte attribute 81 */ 82 readyState:0, 83 /** 84 * send method, allowed values POST and GET 85 */ 86 method:"POST", 87 /** 88 * the url for the call 89 */ 90 url:null, 91 /** 92 * asynchronous request, if set to true then the request happens 93 * asynchronously, if possible. 94 */ 95 async:true, 96 /** 97 * read only response object, containing the response as json/dom representation 98 */ 99 response:null, 100 /** 101 * read only plain text representation of the response 102 */ 103 responseText:null, 104 /** 105 * xml dom readonly representation of the response 106 */ 107 responseXML:null, 108 /** 109 * readonly status code of the response 110 */ 111 status:null, 112 /** 113 * readonly status text of the response 114 */ 115 statusText:null, 116 117 constructor_:function (params) { 118 this._callSuper("constructor_", params); 119 this._initDefaultFinalizableFields(); 120 121 this._XHRConst = myfaces._impl.xhrCore.engine.XhrConst; 122 this._Lang.applyArgs(this, params); 123 }, 124 125 //open send, abort etc... abstract 126 /** 127 * opens the transport element 128 * @param {String} method transport method allowed values <i>POST</i> and <i>GET</i> 129 * @param {String} url optional url 130 * @param {Boolean} async optional param asynchronous transmission if set to true 131 */ 132 open:function (method, url, async) { 133 this._implementThis(); 134 }, 135 /** 136 * send method 137 * @param {Object} formData data to be posted within the request 138 */ 139 send:function (formData) { 140 this._implementThis(); 141 }, 142 /** 143 * appends a key value pair to the request header if possible 144 * @param {String} key the key of the request header entry 145 * @param {String} value the value for the key 146 */ 147 setRequestHeader:function (key, value) { 148 this._implementThis(); 149 }, 150 /** 151 * aborts the transmission 152 */ 153 abort:function () { 154 this._implementThis(); 155 }, 156 157 //empty implementations for the callback handlers 158 /** 159 * callback once the transmission has started 160 * @param evt 161 */ 162 onloadstart:function (evt) { 163 }, 164 onprogress:function (evt) { 165 }, 166 onabort:function (evt) { 167 }, 168 onerror:function (evt) { 169 }, 170 onload:function (evt) { 171 }, 172 ontimeout:function (evt) { 173 }, 174 onloadend:function (evt) { 175 }, 176 onreadystatechange:function (evt) { 177 }, 178 179 _implementThis:function () { 180 throw Error("the function needs to be implemented"); 181 } 182 });