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 
 18 /**
 19  * @class
 20  * @name _IFrameRequest
 21  * @memberOf myfaces._impl.xhrCore
 22  * @extends myfaces._impl.xhrCore._AjaxRequest
 23  * @description specialized implementation of the jsf js ajax request class
 24  * which utilizes an iframe transport for communications to the server
 25  */
 26 _MF_CLS(_PFX_XHR+"_IFrameRequest", myfaces._impl.xhrCore._AjaxRequest,
 27         /** @lends myfaces._impl.xhrCore._IFrameRequest.prototype */
 28         {
 29 
 30     /**
 31      * @constant
 32      * @description request marker that the request is an iframe based request
 33      */
 34     //JX_PART_IFRAME: "javax.faces.partial.iframe",
 35     /**
 36      * @constant
 37      * @description request marker that the request is an apache myfaces iframe request based request
 38      */
 39     MF_PART_IFRAME: "javax.faces.transport.iframe",
 40 
 41     MF_PART_FACES_REQUEST: "javax.faces.request",
 42 
 43 
 44     constructor_: function(args) {
 45         this._callSuper("constructor_", args);
 46     },
 47 
 48     getFormData: function() {
 49         var ret = new myfaces._impl.xhrCore.engine.FormData(this._sourceForm);
 50         //marker that this is an ajax iframe request
 51         //ret.append(this.JX_PART_IFRAME, "true");
 52         ret.append(this.MF_PART_IFRAME, "true");
 53         ret.append(this.MF_PART_FACES_REQUEST, "partial/ajax");
 54 
 55         var viewState = decodeURIComponent(jsf.getViewState(this._sourceForm));
 56         viewState = viewState.split("&");
 57 
 58         //we append all viewstate values which are not part of the original form
 59         //just in case getViewState is decorated
 60         for(var cnt = 0, len = viewState.length; cnt < len; cnt++) {
 61             var currViewState = viewState[cnt];
 62             var keyVal = currViewState.split("=");
 63             var name = keyVal[0];
 64             if(!this._Dom.getNamedElementFromForm(this._sourceForm, name)) {
 65                 ret.append(name, keyVal[1]);
 66             }
 67         }
 68 
 69         return ret;
 70     },
 71 
 72     _formDataToURI: function(/*formData*/) {
 73         //http get alwyays sends the form data
 74         return "";
 75     },
 76 
 77     _getTransport: function() {
 78         return new myfaces._impl.xhrCore.engine.IFrame();
 79     }
 80 
 81 });