1 /* Licensed to the Apache Software Foundation (ASF) under one or more
  2  * contributor license agreements.  See the NOTICE file distributed with
  3  * this work for additional information regarding copyright ownership.
  4  * The ASF licenses this file to you under the Apache License, Version 2.0
  5  * (the "License"); you may not use this file except in compliance with
  6  * the License.  You may obtain a copy of the License at
  7  *
  8  *      http://www.apache.org/licenses/LICENSE-2.0
  9  *
 10  * Unless required by applicable law or agreed to in writing, software
 11  * distributed under the License is distributed on an "AS IS" BASIS,
 12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  * See the License for the specific language governing permissions and
 14  * limitations under the License.
 15  */
 16 /**
 17  * this method is used only for pure multipart form parts
 18  * otherwise the normal method is used
 19  * IT is a specialized request which uses the form data
 20  * element for the handling of forms
 21  */
 22 _MF_CLS(_PFX_XHR + "_MultipartAjaxRequestLevel2", myfaces._impl.xhrCore._AjaxRequest, {
 23 
 24     _sourceForm:null,
 25 
 26     constructor_:function (args) {
 27         this._callSuper("constructor_", args);
 28         //TODO xhr level2 can deal with real props
 29 
 30     },
 31 
 32     getFormData:function () {
 33         var ret;
 34         //in case of a multipart form post we savely can use the FormData object
 35         if (this._context._mfInternal.xhrOp === "multipartQueuedPost") {
 36             ret = new FormData(this._sourceForm);
 37             this._AJAXUTIL.appendIssuingItem(this._source, ret);
 38         } else {
 39             //we switch back to the encode submittable fields system
 40             this._AJAXUTIL.encodeSubmittableFields(ret, this._sourceForm, null);
 41             this._AJAXUTIL.appendIssuingItem(this._source, ret);
 42         }
 43         return ret;
 44     },
 45 
 46     /**
 47      * applies the content type, this needs to be done only for xhr
 48      * level1
 49      * @param xhr
 50      * @private
 51      */
 52     _applyContentType:function (xhr) {
 53         //content type is not set in case of xhr level2 because
 54         //the form data object does it itself
 55     },
 56 
 57     _formDataToURI:function (formData) {
 58         //in xhr level2 form data takes care of the http get parametrisation
 59         return "";
 60     },
 61 
 62     _getTransport:function () {
 63         return new XMLHttpRequest();
 64     }
 65 });
 66 
 67 /**
 68  * for normal requests we basically use
 69  * only the xhr level2 object but
 70  */
 71 _MF_CLS(_PFX_XHR + "_AjaxRequestLevel2", myfaces._impl.xhrCore._AjaxRequest, {
 72 
 73     _sourceForm:null,
 74 
 75     constructor_:function (args) {
 76         this._callSuper("constructor_", args);
 77         //TODO xhr level2 can deal with real props
 78 
 79     },
 80 
 81     _getTransport:function () {
 82         return new XMLHttpRequest();
 83     }
 84 });
 85 
 86 
 87 
 88 
 89