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  * like form data with file uploads.
 19  * This is a replacement for the iframe request which we used until now
 20  * The iframe method works on older browsers but most likely will
 21  * be cut off in future browsers, because there is an alternative
 22  * in form of FormData.
 23  */
 24 _MF_CLS(_PFX_XHR+"_FormDataRequest", myfaces._impl.xhrCore._AjaxRequest, {
 25     _AJAXUTIL: myfaces._impl.xhrCore._AjaxUtils,
 26 
 27     constructor_: function(arguments) {
 28         this._callSuper("constructor_", arguments);
 29 
 30         this._contentType = "multipart/form-data";
 31     },
 32 
 33     /**
 34      * Spec. 13.3.1
 35      * Collect and encode input elements.
 36      * Additionally the hidden element javax.faces.ViewState
 37      * Enhancement partial page submit
 38      *
 39      * @return  an element of formDataWrapper
 40      * which keeps the final Send Representation of the
 41      */
 42     getFormData : function() {
 43         var _AJAXUTIL = this._AJAXUTIL, myfacesOptions = this._context.myfaces, ret = null;
 44 
 45 
 46         //now this is less performant but we have to call it to allow viewstate decoration
 47         if (!this._partialIdsArray || !this._partialIdsArray.length) {
 48             ret = new FormData();
 49             _AJAXUTIL.encodeSubmittableFields(ret, this._sourceForm);
 50             //just in case the source item is outside of the form
 51             //only if the form override is set we have to append the issuing item
 52             //otherwise it is an element of the parent form
 53             if (this._source && myfacesOptions && myfacesOptions.form)
 54                 _AJAXUTIL.appendIssuingItem(this._source, ret);
 55         } else {
 56             ret = new FormData();
 57             _AJAXUTIL.encodeSubmittableFields(ret, this._sourceForm, this._partialIdsArray);
 58             if (this._source && myfacesOptions && myfacesOptions.form)
 59                 _AJAXUTIL.appendIssuingItem(this._source, ret);
 60 
 61         }
 62 
 63         return ret;
 64     },
 65 
 66     _getTransport: function() {
 67         return new XMLHttpRequest();
 68     },
 69 
 70     _applyContentType: function(xhr) {
 71 
 72     }
 73 
 74 });