You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2009/01/23 16:25:24 UTC

svn commit: r737051 - in /myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces: _util/_JSF2Utils.js _util/_TrRequestQueue.js _util/_TrXmlRequest.js _util/_TrXmlRequestEvent.js ajax/Ajax.js ajax/readme.txt

Author: werpu
Date: Fri Jan 23 07:25:24 2009
New Revision: 737051

URL: http://svn.apache.org/viewvc?rev=737051&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2112
https://issues.apache.org/jira/browse/MYFACES-2110

ongoing work in progress not finished yet

Added:
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrRequestQueue.js
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrXmlRequest.js
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrXmlRequestEvent.js
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/readme.txt   (with props)
Modified:
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_JSF2Utils.js
    myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/Ajax.js

Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_JSF2Utils.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_JSF2Utils.js?rev=737051&r1=737050&r2=737051&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_JSF2Utils.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_JSF2Utils.js Fri Jan 23 07:25:24 2009
@@ -1,10 +1,12 @@
-/* 
+
+
+/*
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
  *  You may obtain a copy of the License at
- * 
+ *
  *       http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  *  Unless required by applicable law or agreed to in writing, software
  *  distributed under the License is distributed on an "AS IS" BASIS,
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -13,22 +15,299 @@
  *  under the License.
  */
 
+if('undefined' == typeof org || null == org) {
+    var org = null;
+}
 /**
- *
- * reserve the root namespace for myfaces
+ * A simple provide function
+ * fixing the namespaces
  */
-if('undefined' != typeof OpenAjax && ('undefined' == typeof org || 'undefined' == typeof org.apache || 'undefined' == typeof org.apache.myfaces ||
-                                        null == org || null == org.apache || null == org.apache.myfaces) ) {
-    OpenAjax.hub.registerLibrary("org.apache.myfaces", "myfaces.apache.org", "2.0", null);
+function _provide_Org_Apache_Myfaces() {
+
+    /**
+     *
+     * reserve the root namespace for myfaces
+     */
+    if ('undefined' != typeof OpenAjax && ('undefined' == typeof org || null == org || 'undefined' == typeof org.apache || 'undefined' == typeof org.apache.myfaces ||
+        null == org.apache || null == org.apache.myfaces)) {
+        if(undefined == typeof(org) || null == org) {
+            OpenAjax.hub.registerLibrary("org.apache.myfaces", "myfaces.apache.org", "1.0", null);
+        }
+
+    }
+    /*hub registration failed for whatever reason*/
+    //TODO figure out how to reserve the namespace in a different form
+    if('undefined' == typeof org || null == org) {
+        org = new Object();
+    }
+    if('undefined' == typeof org.apache || null == org.apache) {
+        org.apache = new Object();
+    }
+    if('undefined' == typeof org.apache.myfaces || null == org.apache.myfaces) {
+        org.apache.myfaces = new Object();
+    }
+
 }
 
-if('undefined' == typeof(org.apache.myfaces._JSF2Utils) || null == org.apache.myfaces._JSF2Utils) {
-    org.apache.myfaces._JSF2Utils = function() {
-        var _underTest = false;
+_provide_Org_Apache_Myfaces();
 
-        isUnderTest = function() {
-            return this._underTest;
+/**
+ * Central internal JSF2 Utils with code used
+ * by various aspects of the JSF2 Ajax subsystem
+ * 
+ * Note parts of the code were crossported from the dojo
+ * javascript library (see license.txt for more details 
+ * on the dojo bsd license)
+ */
+if ('undefined' == typeof(org.apache.myfaces._JSF2Utils) || null == org.apache.myfaces._JSF2Utils) {
+    org.apache.myfaces._JSF2Utils = function() {
+        }
+    org.apache.myfaces._JSF2Utils._underTest = false;
+    org.apache.myfaces._JSF2Utils.isUnderTest = function() {
+        return this._underTest;
+    }
+    
+   
+    /**
+     * backported from dojo
+     * Converts an array-like object (i.e. arguments, DOMCollection) to an
+     array. Returns a new Array with the elements of obj.
+     * @param obj the object to "arrayify". We expect the object to have, at a
+     minimum, a length property which corresponds to integer-indexed
+     properties.
+     * @param offset the location in obj to start iterating from. Defaults to 0.
+     Optional.
+     * @param startWith An array to pack with the properties of obj. If provided,
+     properties in obj are appended at the end of startWith and
+     startWith is the returned array.
+     */
+    org.apache.myfaces._JSF2Utils._toArray = function(/*Object*/obj, /*Number?*/offset, /*Array?*/ startWith) {
+        //	summary:
+        //		Converts an array-like object (i.e. arguments, DOMCollection) to an
+        //		array. Returns a new Array with the elements of obj.
+        //	obj:
+        //		the object to "arrayify". We expect the object to have, at a
+        //		minimum, a length property which corresponds to integer-indexed
+        //		properties.
+        //	offset:
+        //		the location in obj to start iterating from. Defaults to 0.
+        //		Optional.
+        //	startWith:
+        //		An array to pack with the properties of obj. If provided,
+        //		properties in obj are appended at the end of startWith and
+        //		startWith is the returned array.
+        var arr = startWith || [];
+        for (var x = offset || 0; x < obj.length; x++) {
+            arr.push(obj[x]);
+        }
+        return arr; // Array
+    };
+    /**
+     * Backported from dojo
+     */
+    org.apache.myfaces._JSF2Utils.isString = function(/*anything*/ it) {
+        //	summary:
+        //		Return true if it is a String
+        return !!arguments.length && it != null && (typeof it == "string" || it instanceof String); // Boolean
+    };
+    /**
+     * hitch backported from dojo
+     * hitch allows to assign a function to a dedicated scope
+     * this is helpful in situations when function reassignments
+     * can happen
+     * (notably happens often in lazy xhr code)
+     */
+    org.apache.myfaces._JSF2Utils.hitch = function(/*Object*/scope, /*Function|String*/method /*,...*/) {
+        //	summary:
+        //		Returns a function that will only ever execute in the a given scope.
+        //		This allows for easy use of object member functions
+        //		in callbacks and other places in which the "this" keyword may
+        //		otherwise not reference the expected scope.
+        //		Any number of default positional arguments may be passed as parameters
+        //		beyond "method".
+        //		Each of these values will be used to "placehold" (similar to curry)
+        //		for the hitched function.
+        //	scope:
+        //		The scope to use when method executes. If method is a string,
+        //		scope is also the object containing method.
+        //	method:
+        //		A function to be hitched to scope, or the name of the method in
+        //		scope to be hitched.
+        //	example:
+        //	|	org.apache.myfaces._JSF2Utils.hitch(foo, "bar")();
+        //		runs foo.bar() in the scope of foo
+        //	example:
+        //	|	org.apache.myfaces._JSF2Utils.hitch(foo, myFunction);
+        //		returns a function that runs myFunction in the scope of foo
+        if (arguments.length > 2) {
+            return org.apache.myfaces._JSF2Utils._hitchArgs._hitchArgs.apply(org.apache.myfaces._JSF2Utils._hitchArgs, arguments); // Function
+        }
+        if (!method) {
+            method = scope;
+            scope = null;
         }
-    }  
+        if (this.isString(method)) {
+            scope = scope || window || function() {};/*since we do not have dojo global*/
+            if (!scope[method]) {
+                throw(['org.apache.myfaces._JSF2Utils: scope["', method, '"] is null (scope="', scope, '")'].join(''));
+            }
+            return function() {
+                return scope[method].apply(scope, arguments || []);
+            }; // Function
+        }
+        return !scope ? method : function() {
+            return method.apply(scope, arguments || []);
+        }; // Function
+    };
+    // Logging helper for use in Firebug
+    /*static*/
+    org.apache.myfaces._JSF2Utils.logWarning = function(varArgs)
+    {
+        if (window.console && console.warn)
+            console.warn(arguments);
+    // else???
+    }
+    // Logging helper for use in Firebug
+    /*static*/
+    org.apache.myfaces._JSF2Utils.logError = function(varArgs)
+    {
+        if (window.console && console.error)
+            console.error(arguments);
+    // else???
+    }
+    org.apache.myfaces._JSF2Utils._hitchArgs = function(scope, method /*,...*/) {
+        var pre = this._toArray(arguments, 2);
+        var named = this.isString(method);
+        return function() {
+            // arrayify arguments
+            var args = this._toArray(arguments);
+            // locate our method
+            var f = named ? (scope || dojo.global)[method] : method;
+            // invoke with collected args
+            return f && f.apply(scope || this, pre.concat(args)); // mixed
+        } // Function
+    };
+    /**
+     * fetches the values of a form and returns
+     * the name/value pairs as javascript map!
+     */
+    org.apache.myfaces._JSF2Utils.getFormMap = function(/*Node*/actionForm, /*map*/ params) {
+        var formElements = actionForm.elements;
+        // 1. build up formParams
+        var formParams = {};
+        var viewStateProcessed = false;
+        if (formElements)
+        {
+            for (var elementIndex = 0; elementIndex < formElements.length; elementIndex++)
+            {
+                var input = formElements[elementIndex];
+                // todo: do not post values for non-triggering submit buttons
+                // TRINIDAD-874 skip input.type="submit" fields
+                if (input.name && !input.disabled && !(input.tagName == "INPUT" && input.type == "submit"))
+                {
+                    if (input.options)
+                    {
+                        formParams[input.name] = new Array();
+                        for (var j = 0; j < input.options.length; j++)
+                        {
+                            var option = input.options[j];
+                            if (option.selected)
+                            {
+                                var optionValue = (option.value === null) ?
+                                option.text : option.value;
+                                formParams[input.name].push(optionValue);
+                            }
+                        }
+                    }
+                    // if this happens to be an unselected checkbox or radio then
+                    // skip it. Otherwise, if it is any other form control, or it is
+                    // a selected checkbox or radio than add it:
+                    else if (!((input.type == "checkbox" ||
+                        input.type == "radio") &&
+                    !input.checked))
+                    {
+                        // the value might already have been set (because of a
+                        // multi-select checkbox group:
+                        var current = formParams[input.name];
+                        if (current)
+                        {
+                            // the value has already been set, so we need to create an array
+                            // and push both values into the array.
+                            // first check to see if we already have an array:
+                            if (!current.join)
+                            {
+                                // we don't have an array so create one:
+                                var list = new Array();
+                                list.push(current);
+                                formParams[input.name] = list;
+                                current = list;
+                            }
+                            // we already have an array, so add the new value to the array:
+                            current.push(input.value);
+                        }
+                        else
+                        {
+                            formParams[input.name] = input.value;
+                        }
+                    }
+                }
+            }
+        }
+        // 2. override formParams with params
+        for (var key in params)
+        {
+            var value = params[key];
+            formParams[key] = params[key];
+        }
+    };
+    /**
+     * fetches the encoding content of a single form element
+     * and attaches the params to the resulting map
+     */
+    /*static*/
+    org.apache.myfaces._JSF2Utils.getPostbackContent = function(/*Node*/actionForm, /*params*/ params)
+    {
+        formParams = org.apache.myfaces._JSF2Utils.getFormMap(actionForm, params);
+        // 3. create form submit payload
+        var content = "";
+        for (var key in formParams)
+        {
+            var paramValue = formParams[key];
+            if (paramValue != null)
+            {
+                // If it's an array...
+                if (paramValue.join)
+                {
+                    var array = paramValue;
+                    for (var i = 0; i < array.length; i++)
+                    {
+                        content = org.apache.myfaces._JSF2Utils._appendUrlFormEncoded(content, key, array[i]);
+                    }
+                }
+                else
+                {
+                    content = org.apache.myfaces._JSF2Utils._appendUrlFormEncoded(content, key, paramValue);
+                }
+            }
+        }
+        return content;
+    }
+    /*helper to append the encoded url params*/
+    /*static*/
+    org.apache.myfaces._JSF2Utils._appendUrlFormEncoded = function(
+        buffer,
+        key,
+        value)
+        {
+        if (buffer.length > 0)
+        {
+            buffer = buffer + "&";
+        }
+        return buffer + key + "=" + value.toString().replace(/\%/g, '%25')
+        .replace(/\+/g, '%2B')
+        .replace(/\//g, '%2F')
+        .replace(/\&/g, '%26')
+        .replace(/\"/g, '%22')
+        .replace(/\'/g, '%27');
+    }
 }
-

Added: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrRequestQueue.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrRequestQueue.js?rev=737051&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrRequestQueue.js (added)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrRequestQueue.js Fri Jan 23 07:25:24 2009
@@ -0,0 +1,610 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+_provide_Org_Apache_Myfaces();
+if ('undefined' == typeof org.apache.myfaces._TrRequestQueue) {
+    /**
+     * The RequestQueue class is a service to serialize the XML HTTP
+     * request communication from the client to the server.
+     */
+    org.apache.myfaces._TrRequestQueue = function(domWindow)
+    {
+        this._state = org.apache.myfaces._TrRequestQueue.STATE_READY;
+        this._requestQueue = new Array();
+        // listeners that are interested in the state change of this service object
+        this._stateChangeListeners = null;
+        //this._iframeLoadCallback = undefined;
+
+        // Stash away the DOM window for later reference.
+        this._window = domWindow;
+    }
+    // Class constants
+    org.apache.myfaces._TrRequestQueue.STATE_READY = 0;
+    org.apache.myfaces._TrRequestQueue.STATE_BUSY = 1;
+    // frame used for multi-part form post
+    org.apache.myfaces._TrRequestQueue._MULTIPART_FRAME = "_trDTSFrame";
+    org.apache.myfaces._TrRequestQueue._XMLHTTP_TYPE = 0;
+    org.apache.myfaces._TrRequestQueue._MULTIPART_TYPE = 1;
+    org.apache.myfaces._TrRequestQueue.prototype.dispose = function()
+    {
+        // TODO aschwart
+        // Check for outstanding requests?
+        this._requestQueue = null;
+        this._stateChangeListeners = null;
+        this._window = null;
+    }
+    org.apache.myfaces._TrRequestQueue._RequestItem = function(
+            type,
+            context,
+            actionURL,
+            headerParams,
+            content,
+            method
+            )
+    {
+        this._type = type;
+        this._context = context;
+        this._actionURL = actionURL;
+        this._headerParams = headerParams;
+        this._content = content;
+        this._method = method;
+    }
+    org.apache.myfaces._TrRequestQueue.prototype._broadcastRequestStatusChanged = function(
+            context, currMethod, event)
+    {
+        if (currMethod)
+        {
+            try
+            {
+                currMethod.call(context, event);
+            }
+            catch (e)
+            {
+                org.apache.myfaces._TrRequestQueue._logError(
+                        "Error ", e, " delivering XML request status changed to ",
+                        currMethod);
+            }
+        }
+    }
+    org.apache.myfaces._TrRequestQueue.prototype._addRequestToQueue = function(
+            type,
+            context,
+            listener,
+            actionURL,
+            content,
+            headerParams
+            )
+    {
+        var newRequest = new org.apache.myfaces._TrRequestQueue._RequestItem(
+                type, context, actionURL, headerParams, content, listener);
+        this._requestQueue.push(newRequest);
+        try
+        {
+            var dtsRequestEvent = new org.apache.myfaces._TrXMLRequestEvent(
+                    org.apache.myfaces._TrXMLRequestEvent.STATUS_QUEUED,
+                    null); // no xmlhttp object at this time
+            this._broadcastRequestStatusChanged(context, listener, dtsRequestEvent);
+        }
+        catch(e)
+        {
+            org.apache.myfaces._TrRequestQueue._logError("Error on listener callback invocation - STATUS_QUEUED", e);
+        }
+        if (this._state == org.apache.myfaces._TrRequestQueue.STATE_READY)
+        {
+            this._state = org.apache.myfaces._TrRequestQueue.STATE_BUSY;
+            this._broadcastStateChangeEvent(org.apache.myfaces._TrRequestQueue.STATE_BUSY);
+            this._doRequest();
+        }
+    }
+    //
+    // HTML-specific API: consider refactoring into a separate class
+    //
+    /**
+     * Send a form post
+     */
+    org.apache.myfaces._TrRequestQueue.prototype.sendFormPost = function(
+            context,
+            method,
+            actionForm,
+            params,
+            headerParams
+            )
+    {
+        if (this._isMultipartForm(actionForm))
+        {
+            // TODO: log a warning if we're dropping any headers?  Or
+            // come up with a hack to send "headers" via a multipart request?
+            this.sendMultipartRequest(context, method, actionForm.action, actionForm, params);
+        }
+        else
+        {
+            var content = this._getPostbackContent(actionForm, params);
+            // IE BUG, see TRINIDAD-704
+            if (_agent.isIE && window.external)
+                window.external.AutoCompleteSaveForm(actionForm);
+            this.sendRequest(context, method, actionForm.action, content, headerParams);
+        }
+    }
+    /**
+     * Returns true if the form has a "file" input that contains
+     * anything to upload.
+     */
+    org.apache.myfaces._TrRequestQueue.prototype._isMultipartForm = function(actionForm)
+    {
+        // If there not enough DOM support, namely getElementsByTagName() being
+        // not supported, this function does not work. Return false for such case.
+        if (!_agent.supportsDomDocument)
+        {
+            return false;
+        }
+        // Use enctype - supported on IE >= 6, Moz, and Safari.
+        // encoding is not supported on Safari.
+        if (actionForm.enctype.toLowerCase() != "multipart/form-data")
+            return false;
+        var inputs = actionForm.getElementsByTagName("input"),
+                inputCount = inputs.length, multiPartForm = null;
+        for (var i = 0; i < inputCount; ++i)
+        {
+            var inputElem = inputs[i];
+            if (inputElem.type == "file" && inputElem.value)
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+    /**
+     * Returns the payload to include in the rich postback
+     * @param actionForm {Element} Form to build up input elements for post in
+     * @param params {Object} Name/value pairs to ensure that the form contains
+     * @return Content encoded correctly in String form
+     */
+    org.apache.myfaces._TrRequestQueue.prototype._getPostbackContent = function(actionForm, params)
+    {
+       return org.apache.myfaces._JSF2Utils.getPostbackContent(actionForm, params)
+    }
+   
+    //
+    // Generic API
+    //
+
+    /**
+     * Performs Asynchronous XML HTTP Request with the Server
+     * @param context    any object that is sent back to the callback when the request
+     *  is complete. This object can be null.
+     * @param method   Javascript method
+     * @param actionURL   the url to send the request to
+     * @param headerParams  Option HTTP header parameters to attach to the request
+     * @param content     the content of the Asynchronous XML HTTP Post
+     */
+    org.apache.myfaces._TrRequestQueue.prototype.sendRequest = function(
+            context,
+            method,
+            actionURL,
+            content,
+            headerParams
+            )
+    {
+        this._addRequestToQueue(org.apache.myfaces._TrRequestQueue._XMLHTTP_TYPE, context, method, actionURL, content, headerParams);
+    }
+    /**
+     * Performs Asynchronous HTTP Request with the Server for multipart data
+     * @param context    any object that is sent back to the callback when the request
+     *  is complete. This object can be null.
+     * @param actionURL  this is the appropriate action url
+     * @param htmlForm    the form containing multi-part data. The action attribute
+     *   of the form is used for send the request to the server
+     * @param params     additional parameters that need to be sent to the server
+     * @param method   Javascript method
+     */
+    org.apache.myfaces._TrRequestQueue.prototype.sendMultipartRequest = function(
+            context,
+            method,
+            actionURL,
+            htmlForm,
+            params
+            )
+    {
+        var privateContext =
+        {"htmlForm":htmlForm, "params": params, "context": context, "method": method};
+        this._addRequestToQueue(org.apache.myfaces._TrRequestQueue._MULTIPART_TYPE, privateContext, null, actionURL);
+    }
+    org.apache.myfaces._TrRequestQueue.prototype._doRequest = function()
+    {
+        // currently we are posting only one request at a time. In future we may batch
+        // mutiple requests in one post
+        var requestItem = this._requestQueue.shift();
+        switch (requestItem._type)
+                {
+            case org.apache.myfaces._TrRequestQueue._XMLHTTP_TYPE:
+                this._doXmlHttpRequest(requestItem);
+                break;
+
+            case org.apache.myfaces._TrRequestQueue._MULTIPART_TYPE:
+                this._doRequestThroughIframe(requestItem);
+                break;
+        }
+    }
+    org.apache.myfaces._TrRequestQueue.prototype._doXmlHttpRequest = function(requestItem)
+    {
+        var xmlHttp = new TrXMLRequest();
+        xmlHttp.__dtsRequestContext = requestItem._context;
+        xmlHttp.__dtsRequestMethod = requestItem._method;
+        var callback = TrUIUtils.createCallback(this, this._handleRequestCallback);
+        xmlHttp.setCallback(callback);
+        // xmlhttp request uses the same charset as its parent document's charset.
+        // There is no need to set the charset.
+        xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+        var headerParams = requestItem._headerParams;
+        if (headerParams != null)
+        {
+            for (var headerName in headerParams)
+            {
+                var currHeader = headerParams[headerName];
+                // handle array parameters by joining them together with comma separators
+                // Test if it's an array via the "join" method
+                if (currHeader["join"])
+                    currHeader = currHeader.join(',')
+                xmlHttp.setRequestHeader(headerName, currHeader);
+            }
+        }
+        xmlHttp.send(requestItem._actionURL, requestItem._content);
+    }
+    org.apache.myfaces._TrRequestQueue.prototype._doRequestThroughIframe = function(requestItem)
+    {
+        var htmlForm = requestItem._context.htmlForm;
+        var actionURL = requestItem._actionURL;
+        var params = requestItem._context.params;
+        // assert(htmlForm.action, "form action cannot be null for multiform post");
+        var frameName = org.apache.myfaces._TrRequestQueue._MULTIPART_FRAME;
+        var domDocument = this._getDomDocument();
+        var hiddenFrame = domDocument.getElementById(frameName), iframeDoc;
+        var agentIsIE = _agent.isIE;
+        if (!hiddenFrame)
+        {
+            hiddenFrame = domDocument.createElement('iframe');
+            hiddenFrame.name = frameName;
+            hiddenFrame.id = frameName;
+            var frameStyle = hiddenFrame.style;
+            frameStyle.top = frameStyle.left = '0px';
+            frameStyle.width = frameStyle.height = '1px'
+            frameStyle.position = 'absolute';
+            frameStyle.visibility = "hidden";
+            domDocument.body.appendChild(hiddenFrame);
+        }
+        if (agentIsIE)
+        {
+            // Why these lines happen to work, I can't say - but remove them,
+            // and the postback actually goes to a new window
+            hiddenFrame = domDocument.frames[frameName];
+            hiddenFrame.name = frameName;
+            iframeDoc = hiddenFrame.document;
+        }
+        else if (_agent.isSafari)
+        {
+            iframeDoc = hiddenFrame.document;
+        }
+        else
+        {
+            iframeDoc = hiddenFrame.contentDocument;
+        }
+        // We may not have a document yet for the IFRAME, since
+        // nothing has been loaded (appears to work this way on Safari)
+        if (iframeDoc && iframeDoc.firstChild)
+            iframeDoc.removeChild(iframeDoc.firstChild);
+        // store our context variables for later use
+        this._dtsContext = requestItem._context.context;
+        this._dtsRequestMethod = requestItem._context.method;
+        this._htmlForm = htmlForm;
+        this._savedActionUrl = htmlForm.action;
+        this._savedTarget = htmlForm.target;
+        // FIXME: why are the next two lines at all necessary?  The form
+        // should already be set to post, and if the action has been
+        // updated since this was queued
+        htmlForm.method = "POST";
+        htmlForm.action = actionURL;
+        htmlForm.target = frameName;
+        this._appendParamNode(domDocument, htmlForm, "Tr-XHR-Message", "true");
+        // FIXME: the "partial" parameter is unnecessary
+        this._appendParamNode(domDocument, htmlForm, "partial", "true");
+        if (params)
+        {
+            for (var key in params)
+            {
+                this._appendParamNode(domDocument, htmlForm, key, params[key]);
+            }
+        }
+        if (this._iframeLoadCallback == null)
+            this._iframeLoadCallback = TrUIUtils.createCallback(this, this._handleIFrameLoad);
+        // IE BUG, see TRINIDAD-704
+        if (_agent.isIE && window.external)
+            window.external.AutoCompleteSaveForm(htmlForm);
+        htmlForm.submit();
+        this._window.setTimeout(this._iframeLoadCallback, 50);
+    }
+    org.apache.myfaces._TrRequestQueue.prototype._appendParamNode = function(domDocument, form, name, value)
+    {
+        // assert(form!=null);
+        var nodes = this._paramNodes;
+        if (!nodes)
+        {
+            nodes = new Array();
+            this._paramNodes = nodes;
+        }
+        var node = domDocument.createElement("input");
+        node.type = "hidden";
+        node.name = name;
+        node.value = value;
+        nodes.push(node);
+        form.appendChild(node);
+    }
+    org.apache.myfaces._TrRequestQueue.prototype._clearParamNodes = function()
+    {
+        var nodes = this._paramNodes;
+        if (nodes)
+        {
+            var form = nodes[0].parentNode;
+            var count = nodes.length;
+            for (var i = 0; i < count; i++)
+            {
+                form.removeChild(nodes[i]);
+            }
+            delete this._paramNodes;
+        }
+    }
+    org.apache.myfaces._TrRequestQueue.prototype._handleIFrameLoad = function()
+    {
+        var domDocument = this._getDomDocument();
+        var agentIsIE = _agent.isIE;
+        var frameName = org.apache.myfaces._TrRequestQueue._MULTIPART_FRAME;
+        var hiddenFrame, iframeDoc;
+        if (agentIsIE)
+        {
+            hiddenFrame = domDocument.frames[frameName];
+            var iframeDoc = hiddenFrame.document;
+        }
+        else
+        {
+            hiddenFrame = domDocument.getElementById(frameName);
+            iframeDoc = hiddenFrame.contentDocument;
+        }
+        try
+        {
+            if (!iframeDoc.documentElement || !iframeDoc.documentElement.firstChild
+                    || (agentIsIE && iframeDoc.readyState != "complete"))
+            {
+                this._window.setTimeout(this._iframeLoadCallback, 50);
+            }
+            else
+            {
+                this._onIFrameLoadComplete(iframeDoc, this._dtsContext,
+                        this._dtsRequestMethod);
+            }
+        }
+        catch(e)
+        {
+            org.apache.myfaces._TrRequestQueue._alertError();
+            org.apache.myfaces._TrRequestQueue._logError("Error while performing request", e);
+            this._htmlForm.action = this._savedActionUrl;
+            this._htmlForm.target = this._savedTarget;
+        }
+    }
+    org.apache.myfaces._TrRequestQueue.prototype._onIFrameLoadComplete = function(
+            iframeDoc,
+            context,
+            requestMethod)
+    {
+        try
+        {
+            var dtsRequestEvent = new TrIFrameXMLRequestEvent(
+                    iframeDoc);
+            this._broadcastRequestStatusChanged(context, requestMethod, dtsRequestEvent);
+        }
+        finally
+        {
+            //cleanup
+            if (iframeDoc.firstChild)
+                iframeDoc.removeChild(iframeDoc.firstChild);
+            this._htmlForm.action = this._savedActionUrl;
+            this._htmlForm.target = this._savedTarget;
+            //clear the parameter nodes
+            this._clearParamNodes();
+            this._requestDone();
+        }
+    }
+    org.apache.myfaces._TrRequestQueue.prototype._handleRequestCallback = function(
+            xmlHttp
+            )
+    {
+        var httpState = xmlHttp.getCompletionState();
+        if (httpState != TrXMLRequest.COMPLETED)
+            return;
+        var statusCode = 0;
+        var failedConnectionText = org.apache.myfaces._TrRequestQueue._getFailedConnectionText();
+        try
+        {
+            statusCode = xmlHttp.getStatus();
+        }
+        catch(e)
+        {
+            // Drop the exception without logging anything.
+            // Firefox will throw an exception on attempting
+            // to get the status of an XMLHttpRequest if
+            // the Http connection  has been closed
+        }
+        if ((statusCode != 200) && (statusCode != 0))
+        {
+            org.apache.myfaces._TrRequestQueue._alertError();
+            org.apache.myfaces._TrRequestQueue._logError("Error StatusCode(",
+                    statusCode,
+                    ") while performing request\n",
+                    xmlHttp.getResponseText());
+        }
+        try
+        {
+            if (statusCode != 0)
+            {
+                var dtsRequestEvent = new org.apache.myfaces._TrXMLRequestEvent(
+                        org.apache.myfaces._TrXMLRequestEvent.STATUS_COMPLETE,
+                        xmlHttp);
+                this._broadcastRequestStatusChanged(
+                        xmlHttp.__dtsRequestContext,
+                        xmlHttp.__dtsRequestMethod,
+                        dtsRequestEvent);
+            }
+        }
+        finally
+        {
+            //cleanup
+            xmlHttp.cleanup();
+            delete xmlHttp;
+            this._requestDone();
+        }
+    }
+    org.apache.myfaces._TrRequestQueue.prototype._requestDone = function()
+    {
+        if (this._requestQueue.length > 0)
+        {
+            // send the next one in the queue
+            this._doRequest();
+        }
+        else
+        {
+            // Reset our state to recieve more requests
+            this._state = org.apache.myfaces._TrRequestQueue.STATE_READY;
+            this._broadcastStateChangeEvent(org.apache.myfaces._TrRequestQueue.STATE_READY);
+        }
+    }
+    /**
+     * Adds a listener to the request queue that is interested in its state change.
+     * The listners are notified in the order that they are added. A listener can cancel
+     * notification to other listeners in the chain by returning false.
+     *
+     * @param {function} listener  listener function to remove
+     * @param {object} instance to pass as this when calling function
+     */
+    org.apache.myfaces._TrRequestQueue.prototype.addStateChangeListener = function(listener, instance)
+    {
+        // assertFunction(listener);
+        // assertObjectOrNull(instance);
+        var stateChangeListeners = this._stateChangeListeners;
+        if (!stateChangeListeners)
+        {
+            stateChangeListeners = new Array();
+            this._stateChangeListeners = stateChangeListeners;
+        }
+        stateChangeListeners.push(listener);
+        stateChangeListeners.push(instance);
+    }
+    /**
+     * Removes a listener from the request queue that is interested in its state change.
+     * @param {function} listener  listener function to remove
+     * @param {object} instance to pass as this when calling function
+     */
+    org.apache.myfaces._TrRequestQueue.prototype.removeStateChangeListener = function(listener, instance)
+    {
+        // assertFunction(listener);
+        // assertObjectOrNull(instance);
+
+        // remove the listener/instance combination
+        var stateChangeListeners = this._stateChangeListeners;
+        // assert(stateChangeListeners, "stateChangeListeners must exist");
+        var length = stateChangeListeners.length;
+        for (var i = 0; i < length; i++)
+        {
+            var currListener = stateChangeListeners[i];
+            i++;
+            if (currListener == listener)
+            {
+                var currInstance = stateChangeListeners[i];
+                if (currInstance === instance)
+                {
+                    stateChangeListeners.splice(i - 1, 2);
+                }
+            }
+        }
+        // remove array, if empty
+        if (stateChangeListeners.length == 0)
+        {
+            this._stateChangeListeners = null;
+        }
+    }
+    /**
+     * Return the current DTS state.
+     * return (int) _state
+     */
+    org.apache.myfaces._TrRequestQueue.prototype.getDTSState = function()
+    {
+        return this._state;
+    }
+    /**
+     * broadcast the state change of the request queue to its listeners
+     */
+    org.apache.myfaces._TrRequestQueue.prototype._broadcastStateChangeEvent = function(state)
+    {
+        var stateChangeListeners = this._stateChangeListeners;
+        // deliver the state change event to the listeners
+        if (stateChangeListeners)
+        {
+            var listenerCount = stateChangeListeners.length;
+            for (var i = 0; i < listenerCount; i++)
+            {
+                try
+                {
+                    var currListener = stateChangeListeners[i];
+                    i++;
+                    var currInstance = stateChangeListeners[i];
+                    if (currInstance != null)
+                        currListener.call(currInstance, state);
+                    else
+                        currListener(state);
+                }
+                catch (e)
+                {
+                    org.apache.myfaces._TrRequestQueue._logError("Error on DTS State Change Listener", e);
+                }
+            }
+        }
+    }
+    org.apache.myfaces._TrRequestQueue.prototype._getDomDocument = function()
+    {
+        return this._window.document;
+    }
+    org.apache.myfaces._TrRequestQueue._getFailedConnectionText = function()
+    {
+        // TODO: get translated connection information
+        return "Connection failed";
+    }
+    org.apache.myfaces._TrRequestQueue._alertError = function()
+    {
+        // TODO: get translated connection information
+        var failedConnectionText = org.apache.myfaces._TrRequestQueue._getFailedConnectionText();
+        if (failedConnectionText != null)
+            alert(failedConnectionText);
+    }
+    // Logging helper for use in Firebug
+    org.apache.myfaces._TrRequestQueue._logWarning = function(varArgs)
+    {
+       org.apache.myfaces._JSF2Utils.logWarning(varArgs);
+    }
+    // Logging helper for use in Firebug
+    org.apache.myfaces._TrRequestQueue._logError = function(varArgs)
+    {
+         org.apache.myfaces._JSF2Utils.logError(varArgs);
+    }
+}
\ No newline at end of file

Added: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrXmlRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrXmlRequest.js?rev=737051&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrXmlRequest.js (added)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrXmlRequest.js Fri Jan 23 07:25:24 2009
@@ -0,0 +1,187 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+_provide_Org_Apache_Myfaces();
+if ('undefined' == typeof org.apache.myfaces._TrXMLRequest) {
+
+    /**
+     * org.apache.myfaces._TrXMLRequest class is a low-level XML HTTP Request
+     * wrapper
+     **/
+    /**
+     * Default constructor. Creates an asynchronous XML HTTP request
+     **/
+    org.apache.myfaces._TrXMLRequest = function()
+    {
+        this.isSynchronous = false;
+        this.callback = null;
+        this._state = org.apache.myfaces._TrXMLRequest.UNINITIALIZED;
+        this.headers = new Object();
+        this.xmlhttp = org.apache.myfaces._TrXMLRequest._createXmlHttpRequest();
+    };
+    /**
+     * Request state constants. See getCompletionState()
+     **/
+    org.apache.myfaces._TrXMLRequest.UNINITIALIZED = 0;
+    org.apache.myfaces._TrXMLRequest.LOADING = 1;
+    org.apache.myfaces._TrXMLRequest.LOADED = 2;
+    org.apache.myfaces._TrXMLRequest.INTERACTIVE = 3;
+    org.apache.myfaces._TrXMLRequest.COMPLETED = 4;
+    /**
+     * Specifies whether the request should be synchronous
+     * Parameters: isSynch - true if request should be synchronous,
+     * false otherwise
+     **/
+    org.apache.myfaces._TrXMLRequest.prototype.setSynchronous =
+    function (isSynch)
+    {
+        this.isSynchronous = isSynch;
+    };
+    /**
+     * Registers request callback for asynchronous requests
+     * The callback will be called each time the state of the
+     * request changes (see getCompletionState())
+     * The callback should have the following siganture:
+     * <void> function (<org.apache.myfaces._TrXMLRequest>request)
+     **/
+    org.apache.myfaces._TrXMLRequest.prototype.setCallback =
+    function (_callback)
+    {
+        this.callback = _callback;
+    };
+    /**
+     * Returns request's completion state (see Request state
+     * constants)
+     **/
+    org.apache.myfaces._TrXMLRequest.prototype.getCompletionState =
+    function()
+    {
+        return this._state;
+    };
+    /**
+     * Returns the HTTP response status.  For example, 200 is OK.
+     */
+    org.apache.myfaces._TrXMLRequest.prototype.getStatus =
+    function()
+    {
+        return this.xmlhttp.status;
+    }
+    /**
+     * Returns the response as an XML document
+     * Note: this method will block if the the request is asynchronous and
+     * has not yet been completed
+     **/
+    org.apache.myfaces._TrXMLRequest.prototype.getResponseXML =
+    function()
+    {
+        return this.xmlhttp.responseXML;
+    }
+    /**
+     * Returns the response as text
+     * Note: this method will block if the the request is asynchronous and
+     * has not yet been completed
+     **/
+    org.apache.myfaces._TrXMLRequest.prototype.getResponseText =
+    function()
+    {
+        return this.xmlhttp.responseText;
+    }
+    /**
+     * Sends an XML HTTP request
+     * Parameters:
+     * url - destination URL
+     * content - XML document or string that should be included in the request's body
+     **/
+    org.apache.myfaces._TrXMLRequest.prototype.send =
+    function(url, content)
+    {
+        var xmlhttp = this.xmlhttp;
+        if (!this.isSynchronous)
+        {
+            var cb = new Function("arguments.callee.obj.__onReadyStateChange();");
+            cb.obj = this;
+            xmlhttp.onreadystatechange = cb;
+        }
+        var method = content ? "POST" : "GET";
+        xmlhttp.open(method, url, !this.isSynchronous);
+        for (var name in this.headers)
+            xmlhttp.setRequestHeader(name, this.headers[name]);
+        // Set some header to indicate the request initiated from
+        // the Trinidad XHR request
+        // =-ags This needs to be revisited
+        xmlhttp.setRequestHeader("Tr-XHR-Message", "true");
+        xmlhttp.send(content);
+        if (this.isSynchronous)
+        {
+            this._state = xmlhttp.readyState;
+        }
+    }
+    org.apache.myfaces._TrXMLRequest.prototype.getResponseHeader =
+    function(name)
+    {
+        return this.xmlhttp.getResponseHeader(name);
+    }
+    org.apache.myfaces._TrXMLRequest.prototype.getAllResponseHeaders =
+    function()
+    {
+        return this.xmlhttp.getAllResponseHeaders();
+    }
+    org.apache.myfaces._TrXMLRequest.prototype.setRequestHeader =
+    function(name, value)
+    {
+        this.headers[name] = value;
+    }
+    org.apache.myfaces._TrXMLRequest._createXmlHttpRequest = function()
+    {
+        var xmlhttp;
+        if (window.XMLHttpRequest)
+        {
+            xmlhttp = new XMLHttpRequest();
+        }
+        else if (window.ActiveXObject)
+        {
+            try
+            {
+                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
+            }
+            catch (e)
+            {
+                try
+                {
+                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
+                }
+                catch (e)
+                {
+                }
+            }
+        }
+        return xmlhttp;
+    }
+    org.apache.myfaces._TrXMLRequest.prototype.__onReadyStateChange =
+    function()
+    {
+        this._state = this.xmlhttp.readyState;
+        if (this.callback)
+            this.callback(this);
+    }
+    org.apache.myfaces._TrXMLRequest.prototype.cleanup = function()
+    {
+        this.callback = null
+        delete this.xmlhttp;
+    }
+}
\ No newline at end of file

Added: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrXmlRequestEvent.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrXmlRequestEvent.js?rev=737051&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrXmlRequestEvent.js (added)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/_util/_TrXmlRequestEvent.js Fri Jan 23 07:25:24 2009
@@ -0,0 +1,149 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * AJAX Request Event class. This object is passed back to the listeners
+ * of a AJAX Service Request. It support Iorg.apache.myfaces._TrXMLRequestEvent pseudo-interface
+ * with the following methods: getStatus, getResponseXML, getResponseText,
+ * isPprResponse, getResponseContentType
+ */
+_provide_Org_Apache_Myfaces();
+if ('undefined' == typeof(org.apache.myfaces._TrXMLRequestEvent)) {
+    org.apache.myfaces._TrXMLRequestEvent = function(
+        status,
+        request
+        )
+        {
+        this._status = status;
+        this._request = request;
+    };
+    org.apache.myfaces._TrXMLRequestEvent.STATUS_QUEUED = 1;
+    org.apache.myfaces._TrXMLRequestEvent.STATUS_SEND_BEFORE = 2;
+    org.apache.myfaces._TrXMLRequestEvent.STATUS_SEND_AFTER = 3;
+    org.apache.myfaces._TrXMLRequestEvent.STATUS_COMPLETE = 4;
+    org.apache.myfaces._TrXMLRequestEvent.prototype.getStatus = function()
+    {
+        return this._status;
+    };
+    /**
+     *
+     */
+    /**
+     * getter for the request, because jsf 2.0 wants to work directly on the object not the facade
+     */
+    org.apache.myfaces._TrXMLRequestEvent.prototype.getRequest = function()
+    {
+        return this._request;
+    };
+    /**
+     * Returns the response of the AJAX Request as an XML document
+     * NOTE: this method is valid only for org.apache.myfaces._TrXMLRequestEvent.STATUS_COMPLETE
+     **/
+    org.apache.myfaces._TrXMLRequestEvent.prototype.getResponseXML = function()
+    {
+        return this._request.getResponseXML();
+    };
+    /**
+     * Returns true if the response XML of the AJAX Request is valid.
+     * NOTE: this method is valid only for org.apache.myfaces._TrXMLRequestEvent.STATUS_COMPLETE
+     **/
+    org.apache.myfaces._TrXMLRequestEvent.prototype._isResponseValidXML = function()
+    {
+        // Note: Mozilla applies default XSLT to XML parse error
+        var responseDocument = this._request.getResponseXML();
+        if (!responseDocument)
+            return false;
+        var docElement = responseDocument.documentElement;
+        if (!docElement)
+            return false;
+        var nodeName = docElement.nodeName;
+        if (!nodeName)
+            nodeName = docElement.tagName;
+        if (nodeName == "parsererror")
+            return false;
+        return true;
+    };
+    /**
+     * Returns the response of the AJAX Request as text.
+     * NOTE: this method is valid only for org.apache.myfaces._TrXMLRequestEvent.STATUS_COMPLETE
+     **/
+    org.apache.myfaces._TrXMLRequestEvent.prototype.getResponseText = function()
+    {
+        return this._request.getResponseText();
+    };
+    /**
+     * Returns the status code of the xml http AJAX Request.
+     * NOTE: this method is valid only for org.apache.myfaces._TrXMLRequestEvent.STATUS_COMPLETE
+     **/
+    org.apache.myfaces._TrXMLRequestEvent.prototype.getResponseStatusCode = function()
+    {
+        return this._request.getStatus();
+    };
+    /**
+     * Returns all the response headers for xml http AJAX Request.
+     * NOTE: this method is valid only for org.apache.myfaces._TrXMLRequestEvent.STATUS_COMPLETE
+     **/
+    org.apache.myfaces._TrXMLRequestEvent.prototype._getAllResponseHeaders = function()
+    {
+        return this._request.getAllResponseHeaders();
+    };
+    /**
+     * Returns a particular response header for xml http Request.
+     * NOTE: this method is valid only for org.apache.myfaces._TrXMLRequestEvent.STATUS_COMPLETE
+     **/
+    org.apache.myfaces._TrXMLRequestEvent.prototype.getResponseHeader = function(
+        name
+        )
+        {
+        // Note: Mozilla chokes when we ask for a response header that does not exist
+        var allHeaders = this._request.getAllResponseHeaders();
+        return (allHeaders.indexOf(name) != -1) ?
+        this._request.getResponseHeader(name)
+        : null;
+    };
+    /**
+     * Returns if whether if is a rich response
+     * NOTE: this method is valid only for org.apache.myfaces._TrXMLRequestEvent.STATUS_COMPLETE
+     **/
+    // TODO: this should likely be deleted or renamed, as it is
+    // not PPR-specific here
+    org.apache.myfaces._TrXMLRequestEvent.prototype.isPprResponse = function()
+    {
+        // todo: do we need to mark rich responses?
+        // var responseType = this.getResponseHeader("Tr-XHR-Response-Type");
+        var isrich = true;
+        if (isrich && (!this._isResponseValidXML()))
+        {
+            org.apache.myfaces._TrRequestQueue._logError("Invalid PPR response." +
+                " The response-headers were:\n" +
+                this._getAllResponseHeaders() +
+                "\n The invalid response was:\n" +
+                this.getResponseText());
+        }
+        return isrich;
+    };
+    /**
+     * Returns if whether if is a rich response
+     * NOTE: this method is valid only for org.apache.myfaces._TrXMLRequestEvent.STATUS_COMPLETE
+     **/
+    org.apache.myfaces._TrXMLRequestEvent.prototype.getResponseContentType = function()
+    {
+        this.getResponseHeader("Content-Type");
+    };
+}    
\ No newline at end of file

Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/Ajax.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/Ajax.js?rev=737051&r1=737050&r2=737051&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/Ajax.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/Ajax.js Fri Jan 23 07:25:24 2009
@@ -25,18 +25,23 @@
  *
  * reserve the root namespace
  */
-if('undefined' != typeof OpenAjax && ('undefined' == typeof javax || null == typeof javax)) {
+if ('undefined' != typeof OpenAjax && ('undefined' == typeof javax || null == typeof javax)) {
     OpenAjax.hub.registerLibrary("javax", "www.sun.com", "1.0", null);
 }
+//just in case openajax has failed (testing environment)
+//under normal circumstances this should not happen
+if ('undefined' == typeof javax || null == javax) {
+    window.javax = new Object();
+}
 
-if('undefined' == typeof javax.faces || null == javax.faces ) {
+if ('undefined' == typeof javax.faces || null == javax.faces) {
     javax.faces = new Object();
 }
-
-if('undefined' == typeof javax.faces.Ajax || null == javax.faces.Ajax ) {
-    javax.faces.Ajax = new function() {};
+if ('undefined' == typeof javax.faces.Ajax || null == javax.faces.Ajax) {
+    javax.faces.Ajax = new function() {
+    };
 }
-
+javax.faces.Ajax._requestQueue = new org.apache.myfaces._TrRequestQueue();
 /**
  * collect and encode data for a given form element (must be of type form)
  * find the javax.faces.ViewState element and encode its value as well!
@@ -49,22 +54,19 @@
      *  typecheck assert!, we opt for strong typing here
      *  because it makes it easier to detect bugs
      */
-
-    if( 'undefined' == typeof(formElement)
-        || null == formElement
-        ||'undefined' == typeof(formElement.nodeValue)
-        || null == formElement.nodeValue 
-        || formElement.nodeValue != "form") {
-
+    if ('undefined' == typeof(formElement)
+            || null == formElement
+            || 'undefined' == typeof(formElement.nodeName)
+            || null == formElement.nodeName
+            || formElement.nodeName != "FORM") {
         throw Exception("javax.faces.Ajax.viewState: param value not of type form!");
-
     }
-/*
-     * TODO #60
-     * https://issues.apache.org/jira/browse/MYFACES-2110
-     */
+    var formValues = {};
+   
+    formValues["javax.faces.viewState"] = document.getElementById("javax.faces.viewState").value;
+    formValues = org.apache.myfaces._JSF2Utils.getPostbackContent(formElement, formValues);
+    return formValues;
 };
-
 /**
  * this function has to send the ajax requests
  *
@@ -80,46 +82,88 @@
  * @param event: any javascript event supported by that object
  * @param options : map of options being pushed into the ajax cycle
  */
-javax.faces.Ajax.ajaxRequest = function(/*Dom*/ element,/*|EVENT|*/ event,/*{|OPTIONS|}*/ options) {
+javax.faces.Ajax.ajaxRequest = function(/*Dom*/ element, /*|EVENT|*/ event, /*{|OPTIONS|}*/ options) {
     //condition asserts!
-    if('undefined' == typeof(element) || null == element) {
+    if ('undefined' == typeof(element) || null == element) {
         throw Exception("javax.faces.Ajax.ajaxRequest: element cannot be null or undefined!");
     }
-    if('undefined' == typeof(options) || null == options) {
+    if ('undefined' == typeof(options) || null == options) {
         throw Exception("javax.faces.Ajax.ajaxRequest: options cannot be null or undefined! it must be at least an empty map!");
     }
-
+    /*according to the specs we only deal with queued asynchronous events in our transport layer!*/
+    javax.faces.Ajax._requestQueue.setSynchronous(false);
+    //TODO drag in the orig element according to the specs
+    if ('undefined' == typeof(options["javax.faces.ajax.partial"] ||
+                              null == typeof(options["javax.faces.ajax.partial"]))) {
+        options["javax.faces.ajax.partial"] = true;
+    }
+    if ('undefined' == typeof(options["javax.faces.ajax.partial"] ||
+                              null == typeof(options["javax.faces.ajax.partial"]))) {
+        options["javax.faces.ajax.partial"] = true;
+    }
+    if ('undefined' == typeof(options["javax.faces.viewState"] ||
+                              null == typeof(options["javax.faces.viewState"]))) {
+        options["javax.faces.viewState"] = document.getElementById("javax.faces.viewState").value;
+    }
+    //TODO add a hitch here
+    //fetch the outer form from the given element
+    var parentForm = element;
+    while ('undefined' == typeof parentForm.nodeName || !"FORM".equals(parentForm.nodeName)) {
+        parentForm = parentForm.parentNode;
+    }
+    javax.faces.Ajax._requestQueue.sendRequest(this, org.apache.myfaces._JSF2Utils.hitch(this, this._trSuccessCallback), parentForm.action);
     /*
      * TODO #61
      * https://issues.apache.org/jira/browse/MYFACES-2112
+     * done
      */
 };
-
+/**
+ * Internal Trinidad
+ * JSF 2.0 callback compatibility handler
+ * since we use trinidad as our transport we have to do it that way
+ */
+javax.faces.Ajax._trSuccessCallback = function(/*_TrXMLRequestEvent*/ event) {
+    this.ajaxResponse(event.getRequest());
+}
 /**
  * processes the ajax response if the ajax request completes successfully
  * @param request the ajax request!
  */
-javax.faces.Ajax.ajaxResponse = function(request) {
-    if('undefined' == typeof(request) || null == request) {
+javax.faces.Ajax.ajaxResponse = function(/*xhr request object*/request) {
+    if ('undefined' == typeof(request) || null == request) {
         throw Exception("javax.faces.Ajax.ajaxResponse: The response cannot be null or empty!");
     }
+    //TODO handle the ppr part here
+    //check the specs on the format of the return xml to do the ppr as expected!
+
+
     /**
      * TODO #62
      * https://issues.apache.org/jira/browse/MYFACES-2114
      */
 };
-
 /**
  * @return the current project state emitted by the server side method:
  * javax.faces.application.Application.getProjectStage()
  */
 javax.faces.Ajax.getProjectStage = function() {
+    
+
+    if ('undefined' == typeof(this._projectStage) ||
+        null == this._projectStage) {
+        //TODO add small templating capabilities to our resource loader
+        //so that the project stage is loaded on the fly!
+        //or solve it with a separate xmlhttprequest
+    }
+
+
 
     /**
      * TODO #62
      * https://issues.apache.org/jira/browse/MYFACES-2115
      */
-    return null;
+    return this._projectStage;
 };
 
 

Added: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/readme.txt
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/readme.txt?rev=737051&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/readme.txt (added)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/readme.txt Fri Jan 23 07:25:24 2009
@@ -0,0 +1 @@
+ongoing work in progress not finished yet

Propchange: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/readme.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/javax/faces/ajax/readme.txt
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL