You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 12:29:30 UTC

[myfaces-trinidad] branch jsf2_ajax created (now ec528aa)

This is an automated email from the ASF dual-hosted git repository.

deki pushed a change to branch jsf2_ajax
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git.


      at ec528aa  Checkpoint

This branch includes the following new commits:

     new cd7c7e8  Create a branch for working on getting JSF2 AJAX working with Trinidad 2
     new e0eb479  TRINIDAD-1704 Committing Pavitra's patch to the private branch
     new 18258a7  TRINIDAD-1704 Add ASF license to files added by Pavitra
     new 73959a8  Add unblocking code
     new 2dd10dd  Force jsf.js to be included
     new 707b01e  Added DOM replace listener and state change listener support with JSF 2 ajax events
     new 4be815f  Add focus restoration code to the JSF ajax calls
     new b542d5c  Add more status indicators
     new b52b4a3  Move the JSF2 AJAX 'switch' code to the request queue and undo the hacks placed in Page.js. Added a switch that we can use to eventually select if JSF2 AJAX is used or not on the client
     new ec528aa  Checkpoint

The 10 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@myfaces.apache.org" <co...@myfaces.apache.org>'].

[myfaces-trinidad] 08/10: Add more status indicators

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch jsf2_ajax
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit b542d5c5eb285b9732299abdca843b93c9ee3ba9
Author: Andrew Robinson <ar...@apache.org>
AuthorDate: Wed Mar 3 23:37:51 2010 +0000

    Add more status indicators
---
 .../src/main/webapp/demos/ajaxPPRDemos.xhtml       | 48 +++++++++++++++-------
 1 file changed, 34 insertions(+), 14 deletions(-)

diff --git a/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml b/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
index bfa48e8..fe9e8d4 100644
--- a/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
+++ b/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
@@ -114,7 +114,11 @@ function setFocus(event)
                                       value="h:commandButton using jsf.ajax.request." id="of13"/>
                 </tr:panelGroupLayout>
                 <tr:spacer width="30" height="10" id="sp12"/>
-                <tr:panelGroupLayout id="pgl12">
+                <tr:panelGroupLayout id="pgl12" layout="vertical">
+                  <f:facet name="separator">
+                    <tr:spacer height="6" id="sp13"/>
+                  </f:facet>
+                  <tr:statusIndicator id="si2" />
                   <tr:panelLabelAndMessage label="Button Clicked: " id="plm10">
                     <tr:outputFormatted id="btnTarget" partialTriggers="axBtn1 axBtn2"
                                         styleUsage="instruction"
@@ -153,11 +157,17 @@ function setFocus(event)
                                   valueChangeListener="#{partialDemoUtil.valueChanged}"/>
                   </tr:subform>
                 </tr:panelGroupLayout>
-                <tr:panelLabelAndMessage label="Input entered: ">
-                  <tr:outputFormatted id="itTarget" partialTriggers="itxt1 ::sf20:itxt2"
-                                      styleUsage="instruction"
-                                      value="#{partialDemoUtil.status.textStateText}"/>
-                </tr:panelLabelAndMessage>
+                <tr:panelGroupLayout id="pgl21" layout="vertical">
+                  <f:facet name="separator">
+                    <tr:spacer height="6" id="sp22"/>
+                  </f:facet>
+                  <tr:statusIndicator id="si3" />
+                  <tr:panelLabelAndMessage label="Input entered: ">
+                    <tr:outputFormatted id="itTarget" partialTriggers="itxt1 ::sf20:itxt2"
+                                        styleUsage="instruction"
+                                        value="#{partialDemoUtil.status.textStateText}"/>
+                  </tr:panelLabelAndMessage>
+                </tr:panelGroupLayout>
               </tr:panelGroupLayout>
             </tr:panelHeader>
             <tr:panelHeader text="Radio Buttons">
@@ -191,23 +201,33 @@ function setFocus(event)
                   </tr:panelGroupLayout>
                 </tr:panelGroupLayout>
                 <tr:spacer width="30" height="10"/>
-                <tr:panelLabelAndMessage label="Selected: ">
-                  <tr:outputFormatted id="rbTarget" partialTriggers="sbr1 sbr2 sbr3 sor1"
-                                      styleUsage="instruction"
-                                      value="#{partialDemoUtil.status.radioStateText}">
-                    <f:convertDateTime pattern="HH:mm:ss"/>
-                  </tr:outputFormatted>
-                </tr:panelLabelAndMessage>
+                <tr:panelGroupLayout id="pgl31" layout="vertical">
+                  <f:facet name="separator">
+                    <tr:spacer height="6" id="sp31"/>
+                  </f:facet>
+                  <tr:statusIndicator id="si4" />
+                  <tr:panelLabelAndMessage label="Selected: ">
+                    <tr:outputFormatted id="rbTarget" partialTriggers="sbr1 sbr2 sbr3 sor1"
+                                        styleUsage="instruction"
+                                        value="#{partialDemoUtil.status.radioStateText}">
+                      <f:convertDateTime pattern="HH:mm:ss"/>
+                    </tr:outputFormatted>
+                  </tr:panelLabelAndMessage>
+                </tr:panelGroupLayout>
               </tr:panelGroupLayout>
             </tr:panelHeader>
             <tr:panelHeader text="Focus Restoration">
               <tr:outputFormatted styleUsage="instruction"
                                   value="The below command button gets the focus on mouse down and its parent is updated by PPR. It should regain focus after the PPR completes." />
-              <tr:panelGroupLayout id="frpgl1" layout="vertical" partialTriggers="frcb1">
+              <tr:panelGroupLayout id="frpgl1" layout="horizontal" partialTriggers="frcb1">
+                <f:facet name="separator">
+                  <tr:spacer width="10" id="sp41"/>
+                </f:facet>
                 <tr:commandButton id="frcb1" text="Demonstrate focus restoration"
                                   partialSubmit="true">
                   <trd:invokeFunctionBehavior function="setFocus" event="mousedown" />
                 </tr:commandButton>
+                <tr:statusIndicator id="si5" />
               </tr:panelGroupLayout>
             </tr:panelHeader>
           </tr:panelGroupLayout>

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.

[myfaces-trinidad] 09/10: Move the JSF2 AJAX 'switch' code to the request queue and undo the hacks placed in Page.js. Added a switch that we can use to eventually select if JSF2 AJAX is used or not on the client

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch jsf2_ajax
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit b52b4a3ce23e443122c8367a095a3fdb51c3aef1
Author: Andrew Robinson <ar...@apache.org>
AuthorDate: Mon Mar 8 20:38:18 2010 +0000

    Move the JSF2 AJAX 'switch' code to the request queue and undo the hacks placed in Page.js. Added a switch that we can use to eventually select if JSF2 AJAX is used or not on the client
---
 .../main/javascript/META-INF/adf/jsLibs/Page.js    | 177 +++++++++------------
 .../META-INF/adf/jsLibs/xhr/RequestQueue.js        | 106 ++++++++----
 .../META-INF/adf/jsLibs/xhr/XMLRequest.js          | 136 ++++++++++++++--
 .../META-INF/adf/jsLibs/xhr/XMLRequestEvent.js     |  20 ++-
 4 files changed, 288 insertions(+), 151 deletions(-)

diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
index 325f52b..75764bb 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
@@ -18,14 +18,15 @@
  */
 function TrPage()
 {
-  jsf.ajax.addOnError(TrUIUtils.createCallback(this, this._jsfAjaxErrorCallback));
-  jsf.ajax.addOnEvent(TrUIUtils.createCallback(this, this._jsfAjaxCallback));
+  if (typeof jsf != "undefined")
+  {
+    jsf.ajax.addOnEvent(TrUIUtils.createCallback(this, this._jsfAjaxCallback));
+  }
 
   this._loadedLibraries = TrPage._collectLoadedLibraries();
   this._requestQueue = new TrRequestQueue(window);
 }
 
-
 /**
  * Get the shared instance of the page object.
  */
@@ -59,20 +60,9 @@ TrPage.prototype.sendPartialFormPost = function(
   headerParams,
   event)
 {
-  var source = "";
-  if (params != null)
-    source = params.source;
-
-  // TODO: move this to the request queue
-  TrPage._delegateToJSFAjax(actionForm, source, event, params);
-
-
-  /** Delegating to jsf.ajax.request(). Do not call the Trinidad PPR request mechanism
-
   this.getRequestQueue().sendFormPost(
     this, this._requestStatusChanged,
-    actionForm, params, headerParams);
-  */
+    actionForm, params, headerParams, event);
 }
 
 TrPage.prototype._requestStatusChanged = function(requestEvent)
@@ -82,9 +72,9 @@ TrPage.prototype._requestStatusChanged = function(requestEvent)
     var statusCode = requestEvent.getResponseStatusCode();
 
     // The server might not return successfully, for example if an
-    // exception is thrown.  When that happens, a non-200 (OK) status
-    // code is returned as part of the HTTP prototcol.
-    if (statusCode == 200)
+    // exception is thrown. When that happens, a status that is below
+    // 200 or 300 or above is returned as part of the HTTP prototcol.
+    if (statusCode >= 200 && statusCode < 300)
     {
       _pprStopBlocking(window);
 
@@ -101,7 +91,14 @@ TrPage.prototype._requestStatusChanged = function(requestEvent)
         // Nokia browser is officially supported.
         if (responseDocument != null)
         {
-          this._handlePprResponse(responseDocument.documentElement);
+          if (requestEvent.isJsfAjaxRequest())
+          {
+            this._handleJsfAjaxResponse(requestEvent);
+          }
+          else
+          {
+            this._handlePprResponse(responseDocument.documentElement);
+          }
         }
       }
       else
@@ -116,7 +113,59 @@ TrPage.prototype._requestStatusChanged = function(requestEvent)
       // wrong - we should do the handling here
       _pprStopBlocking(window);
     }
+  }
+  if (requestEvent.isJsfAjaxRequest())
+  {
+    this._handleJsfAjaxResponse(requestEvent);
+  }
+}
+
+TrPage.prototype._handleJsfAjaxResponse = function(requestEvent)
+{
+  try
+  {
+    var statusCode = requestEvent.getResponseStatusCode();
+    if (statusCode >= 200 && statusCode < 300)
+    {
+      if (this._ajaxOldDomElements)
+      {
+        this._notifyDomReplacementListeners(this._ajaxOldDomElements);
+      }
 
+      if (this._activeNode)
+      {
+        var activeNode = this._activeNode;
+        delete this._activeNode;
+        var index = -1;
+        if (activeNode.id)
+        {
+          for (var i = 0, size = this._ajaxOldDomElement.length; i < size; ++i)
+          {
+            if (TrPage._isDomAncestorOf(activeNode, this._ajaxOldDomElement[i].element))
+            {
+              index = i;
+              break;
+            }
+          }
+          if (index >= 0)
+          {
+            activeNode = document.getElementById(activeNode.id);
+            window._trActiveElement = activeNode;
+            if (activeNode)
+            {
+              activeNode.focus();
+            }
+          }
+        }
+      }
+    }
+    // TODO: do we need to do any additional processing here, for instance,
+    // error processing?
+  }
+  finally
+  {
+    delete this._ajaxOldDomElements;
+    delete this._activeNode;
   }
 }
 
@@ -781,95 +830,19 @@ TrPage._autoSubmit = function(formId, inputId, event, validateForm, params)
   }
 }
 
-/**
- * Causes a partial submit to occur on a given component using the jsf.ajax.request call. The
- * specified component will not be validated (yet).
- * @param formId(String) Id of the form to partial submit.
- * @param inputId(String) Id of the element causing the partial submit.
- * @param event(Event) The javascript event object.
- * @param params(Object} additional parameters to send
- */
-TrPage._delegateToJSFAjax = function(formId, inputId, event, params)
-{
-  var doc = window.document;
-  var source = _getElementById(doc, inputId);
-
-  if (!params)
-    params = {};
-
-  // TODO: add execute and render targets??
-  jsf.ajax.request(source, event, params);
-}
-
 TrPage.prototype._jsfAjaxCallback = function(data)
 {
-  // TODO: move this code into the request queue to stop this gross infringement
-  // of encapsulation
-  switch (data.status)
+  if (data.status == "complete")
   {
-    case "begin":
-      this._requestQueue._state = TrRequestQueue.STATE_BUSY;
-      this._requestQueue._broadcastStateChangeEvent(this._requestQueue._state);
-      break;
-    case "success":
-      var oldElems = this._ajaxOldDomElements;
-      try
-      {
-        this._notifyDomReplacementListeners(oldElems);
-      }
-      finally
-      {
-        delete this._ajaxOldDomElements;
-      }
-      if (this._activeNode)
-      {
-        var activeNode = this._activeNode;
-        delete this._activeNode;
-        var index = -1;
-        if (activeNode.id)
-        {
-          for (var i = 0, size = oldElems.length; i < size; ++i)
-          {
-            if (TrPage._isDomAncestorOf(activeNode, oldElems[i].element))
-            {
-              index = i;
-              break;
-            }
-          }
-          if (index >= 0)
-          {
-            activeNode = document.getElementById(activeNode.id);
-            window._trActiveElement = activeNode;
-            if (activeNode)
-            {
-              activeNode.focus();
-            }
-          }
-        }
-      }
-      this._requestQueue._state = TrRequestQueue.STATE_READY;
-      this._requestQueue._broadcastStateChangeEvent(this._requestQueue._state);
-      break;
-    case "complete": default:
-      _pprStopBlocking(window);
-      // Collect the DOM elements that will be replaced to be able to fire the
-      // DOM replacement events
-      this._ajaxOldDomElements = this._getDomToBeUpdated(data.responseCode, data.responseXML);
-      this._activeNode = _getActiveElement();
-      break;
+    // Collect the DOM elements that will be replaced to be able to fire the
+    // DOM replacement events.
+    // This information is used in the _handleJsfAjaxResponse function that is called
+    // as a result of the request queue firing the XMLRequestEvent.
+    this._ajaxOldDomElements = this._getDomToBeUpdated(data.responseCode, data.responseXML);
+    this._activeNode = _getActiveElement();
   }
 }
 
-TrPage.prototype._jsfAjaxErrorCallback = function(data)
-{
-  // TODO: move this code into the request queue to stop this gross infringement
-  // of encapsulation
-  this._requestQueue._state = TrRequestQueue.STATE_READY;
-  this._requestQueue._broadcastStateChangeEvent(this._requestQueue._state);
-  delete this._ajaxOldDomElements;
-  delete this._activeNode;
-}
-
 TrPage.prototype._notifyDomReplacementListeners = function(dataArray)
 {
   var listeners = this._domReplaceListeners;
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
index fdd3bd7..ff57d71 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
@@ -31,6 +31,9 @@ function TrRequestQueue(domWindow)
 
   // Stash away the DOM window for later reference.
   this._window = domWindow;
+  // TODO: set this via a web.xml configuration parameter as well as checking for presense of the
+  // JSF library
+  this._useJsfBuiltInAjaxForXhr = (typeof jsf != "undefined");
 }
 
 // Class constants
@@ -57,7 +60,8 @@ TrRequestQueue._RequestItem = function(
   actionURL,
   headerParams,
   content,
-  method
+  method,
+  event
   )
 {
   this._type = type;
@@ -66,6 +70,7 @@ TrRequestQueue._RequestItem = function(
   this._headerParams = headerParams;
   this._content = content;
   this._method = method;
+  this._event = event;
 }
 
 TrRequestQueue.prototype._broadcastRequestStatusChanged = function(
@@ -92,11 +97,23 @@ TrRequestQueue.prototype._addRequestToQueue = function(
   listener,
   actionURL,
   content,
-  headerParams
+  headerParams,
+  event
   )
 {
   var newRequest = new TrRequestQueue._RequestItem(
-                          type, context, actionURL, headerParams, content, listener);
+                          type, context, actionURL, headerParams, content, listener, event);
+
+  if (this._useJsfBuiltInAjaxForXhr && type == TrRequestQueue._XMLHTTP_TYPE)
+  {
+    // Since JSF 2 already has a queue, we need not queue the request here, instead we should
+    // immediately process the request
+    this._state = TrRequestQueue.STATE_BUSY;
+    this._broadcastStateChangeEvent(TrRequestQueue.STATE_BUSY);
+    this._doXmlHttpRequest(newRequest);
+    return;
+  }
+
   this._requestQueue.push(newRequest);
 
   try
@@ -131,7 +148,8 @@ TrRequestQueue.prototype.sendFormPost = function(
   method,
   actionForm,
   params,
-  headerParams
+  headerParams,
+  event
   )
 {
   //this retrieves the action url for PPR.  Generally this will be the action property on
@@ -139,7 +157,7 @@ TrRequestQueue.prototype.sendFormPost = function(
   //expando property encoded as a ResourceUrl.  As such, if the expando is available, use it
   //for PPR
   var pprURL;
-  // In mobile browsers like windows mobile ie, getAttribute funtion throws an exception if 
+  // In mobile browsers like windows mobile ie, getAttribute funtion throws an exception if
   // actionForm doesn't contain the attribute "_trinPPRAction".
   try
   {
@@ -149,7 +167,7 @@ TrRequestQueue.prototype.sendFormPost = function(
   {
   }
   var action = pprURL?pprURL:actionForm.action;
-  
+
   if (this._isMultipartForm(actionForm))
   {
     // TODO: log a warning if we're dropping any headers?  Or
@@ -158,13 +176,24 @@ TrRequestQueue.prototype.sendFormPost = function(
   }
   else
   {
-    var content = this._getPostbackContent(actionForm, params);
-
     // IE BUG, see TRINIDAD-704
     if(_agent.isIE)
       this._autoCompleteForm(actionForm);
 
-    this.sendRequest(context, method, action, content, headerParams);
+    if (this._useJsfBuiltInAjaxForXhr)
+    {
+      // JSF 2 AJAX will take the parameters and it will determine the form
+      // content itself, so we should not convert the data to a string or
+      // gather the form values
+      // TODO: log a warning if we're dropping any headers?  Or
+      // come up with a hack to send "headers" via a multipart request?
+      this.sendRequest(context, method, action, params, headerParams, event);
+    }
+    else
+    {
+      var content = this._getPostbackContent(actionForm, params);
+      this.sendRequest(context, method, action, content, headerParams, event);
+    }
   }
 }
 
@@ -349,22 +378,25 @@ TrRequestQueue._appendUrlFormEncoded = function(
 
 /**
 * Performs Asynchronous XML HTTP Request with the Server
-* @param context    any object that is sent back to the callback when the request
+* @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
+* @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
+* @param event The browser event that triggered the request, if any
 */
 TrRequestQueue.prototype.sendRequest = function(
   context,
   method,
   actionURL,
   content,
-  headerParams
+  headerParams,
+  event
   )
 {
-  this._addRequestToQueue(TrRequestQueue._XMLHTTP_TYPE, context, method, actionURL, content, headerParams);
+  this._addRequestToQueue(TrRequestQueue._XMLHTTP_TYPE, context, method, actionURL, content,
+    headerParams, event);
 }
 
 /**
@@ -411,30 +443,42 @@ TrRequestQueue.prototype._doRequest = function()
 
 TrRequestQueue.prototype._doXmlHttpRequest = function(requestItem)
 {
-  var xmlHttp = new TrXMLRequest();
+  var xmlHttp;
+  if (this._useJsfBuiltInAjaxForXhr)
+  {
+    xmlHttp = new TrXMLJsfAjaxRequest(requestItem._event, requestItem._content);
+  }
+  else
+  {
+    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");
+  if (!this._useJsfBuiltInAjaxForXhr)
+  {
+    // 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;
+    var headerParams = requestItem._headerParams;
 
-  if (headerParams != null)
-  {
-    for (var headerName in headerParams)
+    if (headerParams != null)
     {
-      var currHeader =  headerParams[headerName];
+      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(',')
+        // 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.setRequestHeader(headerName, currHeader);
+      }
     }
   }
 
@@ -675,7 +719,7 @@ TrRequestQueue.prototype._handleRequestCallback = function(
     // the Http connection  has been closed
   }
 
-  if ((statusCode != 200) && (statusCode != 0))
+  if ((status < 200 || status >= 300) && (statusCode != 0))
   {
     TrRequestQueue._alertError();
     TrRequestQueue._logError("Error StatusCode(",
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js
index f78fedb..b6ca382 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js
@@ -6,9 +6,9 @@
  *  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
@@ -34,7 +34,6 @@ function TrXMLRequest()
   this.xmlhttp = TrXMLRequest._createXmlHttpRequest();
 }
 
-
 /**
 * Request state constants. See getCompletionState()
 **/
@@ -49,7 +48,7 @@ TrXMLRequest.COMPLETED = 4;
 * Parameters: isSynch - true if request should be synchronous,
 * false otherwise
 **/
-TrXMLRequest.prototype.setSynchronous = 
+TrXMLRequest.prototype.setSynchronous =
 function (isSynch)
 {
   this.isSynchronous = isSynch;
@@ -62,7 +61,7 @@ function (isSynch)
 * The callback should have the following siganture:
 * <void> function (<TrXMLRequest>request)
 **/
-TrXMLRequest.prototype.setCallback = 
+TrXMLRequest.prototype.setCallback =
 function (_callback)
 {
   this.callback = _callback;
@@ -92,7 +91,7 @@ function()
 * Note: this method will block if the the request is asynchronous and
 * has not yet been completed
 **/
-TrXMLRequest.prototype.getResponseXML = 
+TrXMLRequest.prototype.getResponseXML =
 function()
 {
   return this.xmlhttp.responseXML;
@@ -103,7 +102,7 @@ function()
 * Note: this method will block if the the request is asynchronous and
 * has not yet been completed
 **/
-TrXMLRequest.prototype.getResponseText = 
+TrXMLRequest.prototype.getResponseText =
 function()
 {
   return this.xmlhttp.responseText;
@@ -111,7 +110,7 @@ function()
 
 /**
 * Sends an XML HTTP request
-* Parameters: 
+* Parameters:
 * url - destination URL
 * content - XML document or string that should be included in the request's body
 **/
@@ -125,7 +124,7 @@ function(url, content)
     cb.obj = this;
     xmlhttp.onreadystatechange  = cb;
   }
-  
+
   var method = content ? "POST" : "GET";
   xmlhttp.open(method, url, !this.isSynchronous);
   for (var name in this.headers)
@@ -144,20 +143,20 @@ function(url, content)
 }
 
 
-TrXMLRequest.prototype.getResponseHeader = 
+TrXMLRequest.prototype.getResponseHeader =
 function(name)
 {
 
   return this.xmlhttp.getResponseHeader(name);
 }
 
-TrXMLRequest.prototype.getAllResponseHeaders = 
+TrXMLRequest.prototype.getAllResponseHeaders =
 function()
 {
   return this.xmlhttp.getAllResponseHeaders();
 }
 
-TrXMLRequest.prototype.setRequestHeader = 
+TrXMLRequest.prototype.setRequestHeader =
 function(name, value)
 {
   this.headers[name] = value;
@@ -206,4 +205,117 @@ TrXMLRequest.prototype.cleanup =function()
   delete this.xmlhttp;
 }
 
+/**
+ * Wrapper for the JSF AJAX callback data that provides the same
+ * interface as TrXMLRequest to maintain a compatible API to ease
+ * the support of both the legacy code as well as code to integrate
+ * with JSF 2 AJAX
+ */
+function TrXMLJsfAjaxRequest(
+  event,
+  params)
+{
+  this.isSynchronous = false;
+  this.callback = null;
+  this._event = event;
+  this._params = params || new Object();
+  this._status = 0;
+  this._state = TrXMLRequest.UNINITIALIZED;
+}
+TrXMLJsfAjaxRequest.prototype.setCallback = function(value)
+{
+  this.callback = value;
+}
+TrXMLJsfAjaxRequest.prototype.getCompletionState = function()
+{
+  return this._state;
+}
+TrXMLJsfAjaxRequest.prototype.getStatus = function()
+{
+  return this._status;
+}
+TrXMLJsfAjaxRequest.prototype.getResponseXML = function()
+{
+  return this._responseXML;
+}
+TrXMLJsfAjaxRequest.prototype.getResponseText = function()
+{
+  return this._responseText;
+}
+TrXMLJsfAjaxRequest.prototype.cleanup = function()
+{
+  this.callback = null;
+}
+TrXMLJsfAjaxRequest.prototype._ajaxCallback = function(
+  data
+  )
+{
+  switch (data.status)
+  {
+    case "begin":
+      this._state = TrXMLRequest.LOADING;
+      break;
+    case "complete":
+      this._state = TrXMLRequest.LOADED;
+      break;
+    case "success":
+    default:
+      this._state = TrXMLRequest.COMPLETED;
+      break;
+  }
+
+  if (data.status != "begin")
+  {
+    this._status = data.responseCode;
+    this._responseXML = data.responseXML;
+    this._responseText = data.responseText;
+  }
+
+  if (this.callback)
+  {
+    this.callback(this);
+  }
+}
+TrXMLJsfAjaxRequest.prototype.__onerror = function(
+  data
+  )
+{
+  this._state = TrXMLRequest.COMPLETED;
+  this._status = data.responseCode;
+  this._responseXML = data.responseXML;
+  this._responseText = data.responseText;
+  if (this.callback)
+  {
+    this.callback(this);
+  }
+}
+TrXMLJsfAjaxRequest.prototype.send = function()
+{
+  var source = this._params.source ?
+    _getElementById(window.document, this._params.source) : null;
+
+  var ajaxCallback = TrUIUtils.createCallback(this, this._ajaxCallback);
 
+  jsf.ajax.request(
+    source,
+    this._event,
+    {
+      "onevent": ajaxCallback,
+      "onerror": ajaxCallback,
+      "params": this._params
+    });
+
+  // No need for the event anymore, release the resource
+  delete this._event;
+}
+// No-op functions:
+TrXMLJsfAjaxRequest.prototype.setSynchronous =
+TrXMLJsfAjaxRequest.prototype.setRequestHeader = function() {}
+TrXMLJsfAjaxRequest.prototype.getAllResponseHeaders = function()
+{
+  return new Object();
+};
+TrXMLJsfAjaxRequest.prototype.getResponseHeader = function()
+{
+  return null;
+};
\ No newline at end of file
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js
index 56eb95b..ed669d9 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js
@@ -6,9 +6,9 @@
  *  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
@@ -20,7 +20,7 @@
 /**
  * AJAX Request Event class. This object is passed back to the listeners
  * of a AJAX Service Request. It support ITrXMLRequestEvent pseudo-interface
- * with the following methods: getStatus, getResponseXML, getResponseText, 
+ * with the following methods: getStatus, getResponseXML, getResponseText,
  * isPprResponse, getResponseContentType
  */
 function TrXMLRequestEvent(
@@ -56,7 +56,7 @@ TrXMLRequestEvent.prototype.getResponseXML = function()
 * NOTE: this method is valid only for TrXMLRequestEvent.STATUS_COMPLETE
 **/
 TrXMLRequestEvent.prototype._isResponseValidXML = function()
-{         
+{
   // Note: Mozilla applies default XSLT to XML parse error
   var responseDocument = this._request.getResponseXML();
   if (!responseDocument)
@@ -81,7 +81,7 @@ TrXMLRequestEvent.prototype._isResponseValidXML = function()
 * NOTE: this method is valid only for TrXMLRequestEvent.STATUS_COMPLETE
 **/
 TrXMLRequestEvent.prototype.getResponseText = function()
-{  
+{
   return this._request.getResponseText();
 }
 
@@ -147,4 +147,12 @@ TrXMLRequestEvent.prototype.isPprResponse = function()
 TrXMLRequestEvent.prototype.getResponseContentType = function()
 {
   this.getResponseHeader("Content-Type");
-}
\ No newline at end of file
+}
+
+/**
+ * Returns if the request was made by the built in JSF AJAX APIs
+ */
+TrXMLRequestEvent.prototype.isJsfAjaxRequest = function()
+{
+  return (this._request instanceof TrXMLJsfAjaxRequest);
+};
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.

[myfaces-trinidad] 01/10: Create a branch for working on getting JSF2 AJAX working with Trinidad 2

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch jsf2_ajax
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit cd7c7e877f05a8f0cf74efac36c62b75bf29625a
Author: Andrew Robinson <ar...@apache.org>
AuthorDate: Tue Feb 2 19:50:25 2010 +0000

    Create a branch for working on getting JSF2 AJAX working with Trinidad 2

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.

[myfaces-trinidad] 07/10: Add focus restoration code to the JSF ajax calls

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch jsf2_ajax
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit 4be815fe315b8ab3154b9048885152734c03064b
Author: Andrew Robinson <ar...@apache.org>
AuthorDate: Wed Mar 3 23:18:23 2010 +0000

    Add focus restoration code to the JSF ajax calls
---
 .../src/main/webapp/demos/ajaxPPRDemos.xhtml       | 14 ++++++++++
 .../main/javascript/META-INF/adf/jsLibs/Page.js    | 32 +++++++++++++++++++++-
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml b/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
index df31e8f..bfa48e8 100644
--- a/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
+++ b/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
@@ -62,6 +62,10 @@ function init()
   TrPage.getInstance().getRequestQueue().addStateChangeListener(pprStateChangeFunction);
   TrPage.getInstance().addDomReplaceListener(pprDomReplacementFunction);
 }
+function setFocus(event)
+{
+  event.target.focus();
+}
         </trh:script>
       </tr:group>
     </f:facet>
@@ -196,6 +200,16 @@ function init()
                 </tr:panelLabelAndMessage>
               </tr:panelGroupLayout>
             </tr:panelHeader>
+            <tr:panelHeader text="Focus Restoration">
+              <tr:outputFormatted styleUsage="instruction"
+                                  value="The below command button gets the focus on mouse down and its parent is updated by PPR. It should regain focus after the PPR completes." />
+              <tr:panelGroupLayout id="frpgl1" layout="vertical" partialTriggers="frcb1">
+                <tr:commandButton id="frcb1" text="Demonstrate focus restoration"
+                                  partialSubmit="true">
+                  <trd:invokeFunctionBehavior function="setFocus" event="mousedown" />
+                </tr:commandButton>
+              </tr:panelGroupLayout>
+            </tr:panelHeader>
           </tr:panelGroupLayout>
           <tr:panelLabelAndMessage id="plam1" label="Ajax Status Log">
             <tr:inputText id="it1" value="" simple="true" rows="7" columns="100" />
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
index fcc8288..325f52b 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
@@ -63,6 +63,7 @@ TrPage.prototype.sendPartialFormPost = function(
   if (params != null)
     source = params.source;
 
+  // TODO: move this to the request queue
   TrPage._delegateToJSFAjax(actionForm, source, event, params);
 
 
@@ -811,14 +812,41 @@ TrPage.prototype._jsfAjaxCallback = function(data)
       this._requestQueue._broadcastStateChangeEvent(this._requestQueue._state);
       break;
     case "success":
+      var oldElems = this._ajaxOldDomElements;
       try
       {
-        this._notifyDomReplacementListeners(this._ajaxOldDomElements);
+        this._notifyDomReplacementListeners(oldElems);
       }
       finally
       {
         delete this._ajaxOldDomElements;
       }
+      if (this._activeNode)
+      {
+        var activeNode = this._activeNode;
+        delete this._activeNode;
+        var index = -1;
+        if (activeNode.id)
+        {
+          for (var i = 0, size = oldElems.length; i < size; ++i)
+          {
+            if (TrPage._isDomAncestorOf(activeNode, oldElems[i].element))
+            {
+              index = i;
+              break;
+            }
+          }
+          if (index >= 0)
+          {
+            activeNode = document.getElementById(activeNode.id);
+            window._trActiveElement = activeNode;
+            if (activeNode)
+            {
+              activeNode.focus();
+            }
+          }
+        }
+      }
       this._requestQueue._state = TrRequestQueue.STATE_READY;
       this._requestQueue._broadcastStateChangeEvent(this._requestQueue._state);
       break;
@@ -827,6 +855,7 @@ TrPage.prototype._jsfAjaxCallback = function(data)
       // Collect the DOM elements that will be replaced to be able to fire the
       // DOM replacement events
       this._ajaxOldDomElements = this._getDomToBeUpdated(data.responseCode, data.responseXML);
+      this._activeNode = _getActiveElement();
       break;
   }
 }
@@ -838,6 +867,7 @@ TrPage.prototype._jsfAjaxErrorCallback = function(data)
   this._requestQueue._state = TrRequestQueue.STATE_READY;
   this._requestQueue._broadcastStateChangeEvent(this._requestQueue._state);
   delete this._ajaxOldDomElements;
+  delete this._activeNode;
 }
 
 TrPage.prototype._notifyDomReplacementListeners = function(dataArray)

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.

[myfaces-trinidad] 03/10: TRINIDAD-1704 Add ASF license to files added by Pavitra

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch jsf2_ajax
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit 18258a708108c88799bd9688a8e1db4e8881b8b0
Author: Andrew Robinson <ar...@apache.org>
AuthorDate: Wed Feb 3 00:57:57 2010 +0000

    TRINIDAD-1704 Add ASF license to files added by Pavitra
---
 .../context/PartialViewContextFactoryImpl.java         | 18 ++++++++++++++++++
 .../context/PartialViewContextImpl.java                | 18 ++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextFactoryImpl.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextFactoryImpl.java
index c6a543c..0824cc0 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextFactoryImpl.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextFactoryImpl.java
@@ -1,3 +1,21 @@
+/*
+ *  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.
+ */
 package org.apache.myfaces.trinidadinternal.context;
 
 import javax.faces.context.FacesContext;
diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java
index 92a6abe..43346b5 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java
@@ -1,3 +1,21 @@
+/*
+ *  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.
+ */
 package org.apache.myfaces.trinidadinternal.context;
 
 import java.io.IOException;

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.

[myfaces-trinidad] 05/10: Force jsf.js to be included

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch jsf2_ajax
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit 2dd10dd7bc9e8d4ac232dd46575f274285db9b51
Author: Andrew Robinson <ar...@apache.org>
AuthorDate: Thu Feb 25 16:29:38 2010 +0000

    Force jsf.js to be included
---
 .../myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java | 2 ++
 .../myfaces/trinidadinternal/renderkit/core/xhtml/HeadRenderer.java     | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java
index 059a584..2ea2efe 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java
@@ -20,6 +20,7 @@ package org.apache.myfaces.trinidadinternal.renderkit.core.xhtml;
 
 import java.io.IOException;
 
+import javax.faces.application.ResourceDependency;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 
@@ -34,6 +35,7 @@ import org.apache.myfaces.trinidad.render.CoreRenderer;
  * <p>
  * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/renderkit/core/xhtml/DocumentRenderer.java#0 $) $Date: 10-nov-2005.19:01:25 $
  */
+@ResourceDependency(target = "head", library = "javax.faces", name = "jsf.js")
 public class DocumentRenderer extends XhtmlRenderer
 {
   public DocumentRenderer()
diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HeadRenderer.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HeadRenderer.java
index 9bc97d7..f8c9ace 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HeadRenderer.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HeadRenderer.java
@@ -20,6 +20,7 @@ package org.apache.myfaces.trinidadinternal.renderkit.core.xhtml;
 
 import java.io.IOException;
 
+import javax.faces.application.ResourceDependency;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
@@ -36,6 +37,7 @@ import org.apache.myfaces.trinidad.render.CoreRenderer;
  * <p>
  * @version $Name:  $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/renderkit/core/xhtml/HeadRenderer.java#0 $) $Date: 10-nov-2005.19:01:29 $
  */
+@ResourceDependency(target = "head", library = "javax.faces", name = "jsf.js")
 public class HeadRenderer extends XhtmlRenderer
 {
   public HeadRenderer()

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.

[myfaces-trinidad] 02/10: TRINIDAD-1704 Committing Pavitra's patch to the private branch

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch jsf2_ajax
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit e0eb4794f70e66e13861da1228009c0fe2bc7d19
Author: Andrew Robinson <ar...@apache.org>
AuthorDate: Wed Feb 3 00:51:10 2010 +0000

    TRINIDAD-1704 Committing Pavitra's patch to the private branch
---
 .../src/main/webapp/WEB-INF/trinidad-config.xml    |   2 +-
 .../trinidad-demo/src/main/webapp/WEB-INF/web.xml  |   9 +-
 .../src/main/webapp/demos/ajaxPPRDemos.jspx        | 198 ++++++++++
 .../src/main/conf/META-INF/faces-config-base.xml   |   3 +
 .../context/PartialViewContextFactoryImpl.java     |  28 ++
 .../context/PartialViewContextImpl.java            | 437 +++++++++++++++++++++
 .../renderkit/core/CoreRenderKit.java              |  22 +-
 .../renderkit/core/ppr/PPRResponseWriter.java      | 121 ++++--
 .../renderkit/core/xhtml/CommandLinkRenderer.java  |   2 +-
 .../main/javascript/META-INF/adf/jsLibs/Core.js    |  12 +-
 .../main/javascript/META-INF/adf/jsLibs/Page.js    |  39 +-
 11 files changed, 834 insertions(+), 39 deletions(-)

diff --git a/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml b/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml
index af3f1a5..217b932 100644
--- a/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml
+++ b/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml
@@ -19,7 +19,7 @@
 	   
 -->
 <trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">
-  <debug-output>true</debug-output>
+  <!--debug-output>true</debug-output-->
   <!-- Uncomment to switch back to ALERT style client-side validation,
     or set to DISABLED to disable it altogether
   <client-validation>ALERT</client-validation>
diff --git a/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml b/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml
index ba33d24..a6797c0 100644
--- a/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml
+++ b/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml
@@ -67,10 +67,10 @@
 
   <!-- Trinidad by default uses an optimized client-side state saving
        mechanism. To disable that, uncomment the following -->
-  <!--context-param>
+  <context-param>
     <param-name>org.apache.myfaces.trinidad.CLIENT_STATE_METHOD</param-name>
-    <param-value>all</param-value>
-  </context-param-->
+    <param-value>token</param-value>
+  </context-param>
 <!-- When token client-side state saving is enabled, MyFaces Trinidad can apply an additional
      optimization by caching an entire UIViewRoot tree with each token. 
      (Note that this does not affect thread safety or session failover.) 
@@ -100,9 +100,8 @@
 
   <context-param>
     <param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
-    <param-value>*.xhtml</param-value>
     <!-- to run facelets for jspx files comment the line above and uncomment line below-->
-    <!--param-value>*.xhtml;*.jspx</param-value-->
+    <param-value>*.xhtml;*.jspx</param-value>
   </context-param>
 
   <context-param>
diff --git a/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.jspx b/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.jspx
new file mode 100644
index 0000000..9fb3ad4
--- /dev/null
+++ b/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.jspx
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!--
+    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.
+	   
+-->
+<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
+          xmlns:f="http://java.sun.com/jsf/core"
+          xmlns:h="http://java.sun.com/jsf/html"
+          xmlns:trh="http://myfaces.apache.org/trinidad/html"
+          xmlns:tr="http://myfaces.apache.org/trinidad">
+ <jsp:directive.page contentType="text/html;charset=utf-8"/>
+ <f:view>
+  <h:outputScript name="jsf.js" library="javax.faces" target="body" id="os"/>
+  <tr:document title="Partial Page Rendering Demos">
+    <tr:form>
+
+     <tr:panelPage>
+      <f:facet name="navigationGlobal">
+       <tr:navigationPane hint="buttons">
+        <tr:commandNavigationItem text="Return to Feature Demos page"
+                                immediate="true"
+                                action="demos"/>
+       </tr:navigationPane>
+      </f:facet>
+
+      <tr:panelHeader text="Welcome to the Apache Trinidad Partial Page Rendering Demos for JSF 2.0 Ajax">
+        <tr:outputFormatted styleUsage="instruction" id="of0"
+                            value="These demos test Trinidad PPR with JSF 2.0 Ajax using both 
+                            trinidad and JSF components."/>
+        <tr:panelGroupLayout layout="vertical">
+          <f:facet name="separator">
+            <tr:spacer width="30" height="10"/>
+          </f:facet>
+          <tr:panelHeader text="Command components using JSF 2.0 native Ajax support" id="phCmd">
+            <tr:outputFormatted styleUsage="instruction" id="of10"
+                                value="Tests commandButton components wired to use either Ajax JS API
+                                by itself or both JSF 2 Ajax and trinidad PPR. Clicking these buttons 
+                                should cause a partial or a full page submit (without errors) and 
+                                update the field on the right."/>
+            <tr:spacer height="10" id="sp10"/>
+            <tr:panelGroupLayout layout="horizontal" id="pgl10">
+              <tr:panelGroupLayout layout="vertical" id="pgl11">
+                <f:facet name="separator">
+                  <tr:spacer height="6" id="sp11"/>
+                </f:facet>
+                <tr:outputFormatted styleUsage="instruction" value="tr:commandButton using 
+                    jsf.ajax.request and partialSubmit=true." id="of11"/>
+                <tr:commandButton id="axBtn1"
+                                partialSubmit="true"
+                                text="Partial Submit"
+                                shortDesc="partialSubmit"
+                                actionListener="#{partialDemoUtil.action}"/>
+                  <!--f:ajax event="action" render=""/-->
+                <tr:outputFormatted styleUsage="instruction" value="tr:commandButton using jsf.ajax.request." 
+                 id="of12"/>
+                <tr:commandButton id="axBtn2"
+                                  text="Full Submit"
+                                  shortDesc="fullSubmit"
+                                  actionListener="#{partialDemoUtil.action}"/>
+                
+                <tr:outputFormatted styleUsage="instruction" value="h:commandButton using jsf.ajax.request." 
+                 id="of13"/>
+                
+                
+              </tr:panelGroupLayout>
+              
+              <tr:spacer width="30" height="10" id="sp12"/>
+             
+              <tr:panelGroupLayout id="pgl12">
+                <tr:panelLabelAndMessage label="Button Clicked: " id="plm10">
+                  <tr:outputFormatted id="btnTarget"
+                                     partialTriggers="axBtn1 axBtn2"
+                                     styleUsage="instruction"
+                                     value="#{partialDemoUtil.status.linkUpdate}">
+                    <f:convertDateTime pattern="HH:mm:ss"/>
+                  </tr:outputFormatted>
+                </tr:panelLabelAndMessage>
+             </tr:panelGroupLayout>
+           </tr:panelGroupLayout>
+         </tr:panelHeader>
+       
+         <tr:panelHeader text="InputText Component using JSF 2.0 Ajax" id="phInput">
+           <tr:outputFormatted styleUsage="instruction"
+                             value="Tests autoSubmitting text fields which is also wired to use JSF 
+                             2.0 Ajax."/>
+            <tr:panelGroupLayout layout="horizontal" id="pgl20">
+              <f:facet name="separator">
+                <tr:spacer height="10" id="sp20"/>
+              </f:facet>
+              <tr:panelGroupLayout layout="vertical" id="pgl21">
+                <f:facet name="separator">
+                  <tr:spacer height="6" id="sp21"/>
+                </f:facet>
+                <tr:outputFormatted styleUsage="instruction" value="tr:inputText with
+                    autoSubmit=true." id="of20"/>
+                <tr:inputText id="itxt1"
+                              autoSubmit="true"
+                              value="#{partialDemoUtil.status.textValue}"
+                              label="Enter text and tab out: "
+                              valueChangeListener="#{partialDemoUtil.valueChanged}"/>
+                <tr:outputFormatted styleUsage="instruction" value="tr:inputText with
+                    autoSubmit=true inside a subform" id="of21"/>                
+                <tr:subform id="sf20">
+                  <tr:inputText autoSubmit="true" id="itxt2" label="Enter a different text and tab out: "
+                                 value="#{partialDemoUtil.status.textValue}"
+                                 valueChangeListener="#{partialDemoUtil.valueChanged}"/>
+                </tr:subform>
+              </tr:panelGroupLayout>
+              
+              <tr:panelLabelAndMessage label="Input entered: ">
+               <tr:outputFormatted id="itTarget"
+                                   partialTriggers="itxt1 ::sf20:itxt2"
+                                   styleUsage="instruction"
+                                   value="#{partialDemoUtil.status.textStateText}"/>
+              </tr:panelLabelAndMessage>
+            </tr:panelGroupLayout>
+         </tr:panelHeader>
+         
+         <tr:panelHeader text="Radio Buttons">
+           <tr:outputFormatted styleUsage="instruction"
+                               value="This demo shows a two sets of radio buttons which use autoSubmit. 
+                               There is also an output component which is listening on updates to the 
+                               radio buttons and displaying status text accordingly."/>
+          <tr:panelGroupLayout layout="horizontal">
+           <tr:panelGroupLayout layout="vertical">
+            <tr:panelGroupLayout layout="horizontal">
+             <tr:outputFormatted styleUsage="instruction"
+                                 value="selectBooleanRadio buttons"/>
+             <tr:panelGroupLayout layout="vertical">
+              <tr:selectBooleanRadio id="sbr1"
+                                     group="theGroup"
+                                     selected="false"
+                                     text="item 1"
+                                     autoSubmit="true"
+                                     valueChangeListener="#{partialDemoUtil.valueChanged}"/>
+              <tr:selectBooleanRadio id="sbr2"
+                                     group="theGroup"
+                                     text="item 2"
+                                     selected="false"
+                                     autoSubmit="true"
+                                     valueChangeListener="#{partialDemoUtil.valueChanged}"/>
+              <tr:selectBooleanRadio id="sbr3"
+                                     group="theGroup"
+                                     text="item 3"
+                                     selected="false"
+                                     autoSubmit="true"
+                                     valueChangeListener="#{partialDemoUtil.valueChanged}"/>
+             </tr:panelGroupLayout>
+            </tr:panelGroupLayout>
+            <tr:spacer width="30" height="10"/>
+            <tr:panelGroupLayout layout="vertical">
+             <tr:selectOneRadio id="sor1"
+                                label="selectOneRadio buttons"
+                                autoSubmit="true"
+                                valueChangeListener="#{partialDemoUtil.valueChanged}">
+              <tr:selectItem label="item 1" value="1" />
+              <tr:selectItem label="item 2" value="2" />
+              <tr:selectItem label="item 3" value="3" />
+             </tr:selectOneRadio>
+            </tr:panelGroupLayout>
+           </tr:panelGroupLayout>
+           <tr:spacer width="30" height="10"/>
+           <tr:panelLabelAndMessage label="Selected: ">
+            <tr:outputFormatted id="rbTarget"
+                                partialTriggers="sbr1 sbr2 sbr3 sor1"
+                                styleUsage="instruction"
+                                value="#{partialDemoUtil.status.radioStateText}">
+             <f:convertDateTime pattern="HH:mm:ss"/>
+            </tr:outputFormatted>
+           </tr:panelLabelAndMessage>
+          </tr:panelGroupLayout>
+         </tr:panelHeader>         
+
+
+      </tr:panelGroupLayout>
+     </tr:panelHeader>
+     </tr:panelPage>
+     
+    </tr:form>
+  
+  </tr:document>
+ </f:view>
+</jsp:root>
diff --git a/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml b/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml
index 382feaf..d47f07f 100644
--- a/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml
+++ b/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml
@@ -39,6 +39,9 @@
     <faces-context-factory>
       org.apache.myfaces.trinidadinternal.context.FacesContextFactoryImpl
     </faces-context-factory>
+    <partial-view-context-factory>
+      org.apache.myfaces.trinidadinternal.context.PartialViewContextFactoryImpl
+    </partial-view-context-factory>
   </factory>
 
   <lifecycle>
diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextFactoryImpl.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextFactoryImpl.java
new file mode 100644
index 0000000..c6a543c
--- /dev/null
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextFactoryImpl.java
@@ -0,0 +1,28 @@
+package org.apache.myfaces.trinidadinternal.context;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.FacesContextFactory;
+import javax.faces.context.PartialViewContext;
+import javax.faces.context.PartialViewContextFactory;
+
+public class PartialViewContextFactoryImpl
+  extends PartialViewContextFactory
+{
+  public PartialViewContextFactoryImpl(PartialViewContextFactory factory)
+  {
+    _factory = factory;
+  }
+
+  /**
+   * Creates a PartialViewContext instance that is optimized for Trinidad PPR.
+   * @param context 
+   * @return a PartialViewContext instance
+   */
+  public PartialViewContext getPartialViewContext(FacesContext context)
+  {
+    return new PartialViewContextImpl(context);
+  }
+  
+  private final PartialViewContextFactory _factory;
+  
+}
diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java
new file mode 100644
index 0000000..92a6abe
--- /dev/null
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java
@@ -0,0 +1,437 @@
+package org.apache.myfaces.trinidadinternal.context;
+
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.List;
+
+import java.util.Set;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.PartialResponseWriter;
+import javax.faces.context.PartialViewContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.PhaseId;
+
+import org.apache.myfaces.trinidad.component.UIXComponent;
+import org.apache.myfaces.trinidad.component.visit.VisitCallback;
+import org.apache.myfaces.trinidad.component.visit.VisitContext;
+import org.apache.myfaces.trinidad.component.visit.VisitHint;
+import org.apache.myfaces.trinidad.component.visit.VisitResult;
+import org.apache.myfaces.trinidad.context.PartialPageContext;
+import org.apache.myfaces.trinidad.context.RenderingContext;
+import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidadinternal.renderkit.core.ppr.PPRResponseWriter;
+import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PartialPageUtils;
+
+public class PartialViewContextImpl extends PartialViewContext
+{
+  public PartialViewContextImpl(FacesContext context) 
+  {
+    _context = context;
+  }
+
+  /**
+   * To force a full execute we always return an empty execute list.
+   * @return
+   */
+  public Collection<String> getExecuteIds()
+  {
+    /*
+    if (_executeIds == null) 
+    {
+      String executeStr = _facesContext.getExternalContext().getRequestParameterMap().get(
+        PartialViewContext.PARTIAL_EXECUTE_PARAM_NAME);
+    }
+    else
+    {
+      _executeIds = new ArrayList<String>();
+    }
+    */ 
+    _executeIds = new ArrayList<String>();
+    return _executeIds;
+  }
+
+  public Collection<String> getRenderIds()
+  {
+    return Collections.emptySet();
+  }
+
+  /**
+   * Return a PartialResponseWriter that consumes the Trinidad PprResponseWriter. 
+   * @return
+   */
+  public PartialResponseWriter getPartialResponseWriter()
+  {
+    if (_partialResponseWriter == null) 
+    {
+      _partialResponseWriter = new PPRPartialResponseWriter(_context.getResponseWriter());
+    }
+    return _partialResponseWriter;
+  }
+
+  public boolean isAjaxRequest()
+  {
+    _assertNotReleased();
+    if (_ajaxRequest == null) 
+    {
+        _ajaxRequest = _PARTIAL_AJAX.equals(_context.
+            getExternalContext().getRequestHeaderMap().get(_FACES_REQUEST));
+    }
+    return _ajaxRequest;
+  }
+
+  public boolean isPartialRequest()
+  {
+    _assertNotReleased();
+    if (_partialRequest == null) {
+        _partialRequest = isAjaxRequest() ||
+                _PARTIAL_PROCESS.equals(_context.
+                getExternalContext().getRequestHeaderMap().get(_FACES_REQUEST));
+    }
+    return _partialRequest;  
+  }
+
+  /**
+   * Trinidad PPR currently does a full decode/validate/update. So we return 'false' here, but in 
+   * processPartial, turn into a 'full tree visit'.
+   * @return true as the default executeList is set to be '@all'.
+   */
+  public boolean isExecuteAll()
+  {
+    _assertNotReleased();
+    String execute = _context.getExternalContext().getRequestParameterMap()
+      .get(PARTIAL_EXECUTE_PARAM_NAME);
+    
+    return execute.equals(this.ALL_PARTIAL_PHASE_CLIENT_IDS);
+  }
+
+  public boolean isRenderAll()
+  {
+    _assertNotReleased();
+    if (_renderAll == null) {
+        String render = _context.getExternalContext().getRequestParameterMap()
+                .get(PARTIAL_RENDER_PARAM_NAME);
+        _renderAll = (ALL_PARTIAL_PHASE_CLIENT_IDS.equals(render));
+    }
+
+    return _renderAll;  
+  }
+
+  public void setRenderAll(boolean renderAll)
+  {
+    _renderAll = renderAll;
+  }
+
+  public void setPartialRequest(boolean isPartialRequest)
+  {
+    _partialRequest = isPartialRequest;
+  }
+
+  public void release()
+  {
+    _ajaxRequest = null;
+    _executeIds = null;
+    _context = null;
+    _partialRequest = null;
+    _partialResponseWriter = null;
+    _released = true;
+    _renderAll = null;
+    _renderIds = null;
+  }
+
+  /**
+   * Handles the render phase alone as we perform a full 'execute' always.
+   * 
+   * @param phaseId
+   */
+  public void processPartial(PhaseId phaseId)
+  {
+    UIViewRoot viewRoot = _context.getViewRoot();
+    if (phaseId == PhaseId.APPLY_REQUEST_VALUES ||
+        phaseId == PhaseId.PROCESS_VALIDATIONS ||
+        phaseId == PhaseId.UPDATE_MODEL_VALUES)
+    {
+      // Assume the executeIds is set to @all to mimic a full tree visit. 
+      // Create a FullVisitContext
+      Collection <String> executeIds = getExecuteIds();
+
+      try 
+      {
+        _processExecute(viewRoot, phaseId, executeIds);
+      } 
+      catch (Exception e) 
+      {
+          // RELEASE_PENDING LOG EXCEPTION
+      }
+      
+    }
+    else if (phaseId == PhaseId.RENDER_RESPONSE)
+    {
+      _processRender(viewRoot, phaseId);
+    }
+
+  }
+
+  /**
+   * Performs a 'full' execute if executeIds is empty, in order to build the partialTrigger 
+   * listeners. Later, support for an 'optimized execute' will be added that 'visits' the executeId 
+   * components using the Trinidad visitTree implementation (that accounts for setup/teardown of 
+   * contexts.)
+   * @param component the UIViewRoot
+   * @param phaseId
+   * @param executeIds the Collection of ids to execute
+   */
+  private void _processExecute(
+    UIViewRoot component, 
+    PhaseId phaseId,
+    Collection<String> executeIds)
+  {
+    if (executeIds == null || executeIds.isEmpty())
+    {
+      // We use the tree visitor mechanism to locate the components to process. For now we ignore the 
+      // executeIds as we always want to perform a full decode. So a FullVisitContext is created and 
+      // the VisitCallback invoked for every component in the tree. 
+      VisitContext visitContext = 
+        RequestContext.getCurrentInstance().createVisitContext(_context, 
+                                                               executeIds, 
+                                                               _EXECUTE_VISIT_HINTS, 
+                                                               phaseId);
+      VisitCallback visitCallback = new ExecuteAllCallback(_context, phaseId);
+      UIXComponent.visitTree(visitContext, component, visitCallback);
+    }
+    else
+    {
+      // TODO: optimized decode??  
+    }
+  }
+
+  /**
+   * Performs a partial optimized rendering, if PPROptimization is enabled, otherwise defaults to a 
+   * full render. 
+   * 
+   * @param viewRoot
+   * @param phaseId
+   */
+  private void _processRender(UIComponent viewRoot, PhaseId phaseId)
+  {
+    boolean documentStarted = false;
+    
+    PartialResponseWriter partialResponseWriter = getPartialResponseWriter();
+    // Hold onto the original writer for later
+    ResponseWriter origResponseWriter = _context.getResponseWriter();
+    _context.setResponseWriter(partialResponseWriter);
+
+    ExternalContext extContext = _context.getExternalContext();
+    extContext.setResponseContentType(_RESPONSE_CONTENT_TYPE);
+    extContext.addResponseHeader("Pragma", "no-cache");
+    extContext.addResponseHeader("Cache-control", "no-cache");
+
+    try
+    {
+      partialResponseWriter.startDocument();
+      documentStarted = true;
+    
+      // determine whether we should try and optimize the PPR rendering
+      boolean encodeAllChildren = !PartialPageUtils.isOptimizedPPREnabled(_context, true);
+      
+      if (encodeAllChildren)
+      {
+        // We are guaranteed to be called on UIViewRoot. 
+        if (!viewRoot.isRendered()) 
+        {
+          return;
+        }
+      
+        // No PPR optimization, so encode all children
+        Iterator<UIComponent> children = viewRoot.getFacetsAndChildren();
+        while (children.hasNext()) 
+        {
+          children.next().encodeAll(_context);
+        }
+        
+        // TODO: Explcitly render out the view state as an update element.
+        _renderViewState(partialResponseWriter);
+      }
+      else
+      {
+        // TODO 
+        // HINT: PartialPageContext already creates a partial visit context. Reuse it??
+        
+        // Only visit tree if renderIds exist
+        Collection <String> renderIds = getRenderIds();
+        if (renderIds != null && !renderIds.isEmpty())
+        {
+          // perform an optimized partial visit of the children
+          RenderingContext rContext = RenderingContext.getCurrentInstance();
+          PartialPageContext pprContext = rContext.getPartialPageContext();
+         
+          VisitContext visitContext = pprContext.getVisitContext();
+          // component.visitTree(visitContext, new PhaseAwareVisitCallback(_context, phaseId));
+        }
+      }
+    }
+    catch (IOException e)
+    {
+      // launder the IOException as a FacesException, we'll unwrap this later
+      throw new FacesException(e);        
+    }
+    finally
+    {
+      try
+      {
+        if (documentStarted)
+        {
+          partialResponseWriter.endDocument();
+          documentStarted = false;
+        }
+      }
+      catch (IOException ioe2)
+      {
+        // TODO log exception
+      }
+      _context.setResponseWriter(origResponseWriter);
+    }
+  }
+  
+  private void _renderViewState(PartialResponseWriter writer)
+    throws IOException
+  {
+    // Get the view state and write it to the response..
+    writer.startUpdate(PartialResponseWriter.VIEW_STATE_MARKER);
+    String state = _context.getApplication().getStateManager().getViewState(_context);
+    writer.write(state);
+    writer.endUpdate();    
+  }
+  
+  @SuppressWarnings({"FinalPrivateMethod"})
+  private final void _assertNotReleased() 
+  {
+    if (_released) {
+        throw new IllegalStateException();
+    }
+  }
+
+
+
+
+  /**
+   * A simple PartialRepsonseWriter implementation that delegates most of its calls to the
+   * PPRResponseWriter as it already has the smarts to generate XML partial Ajax responses using the
+   * Trinidad partialTriggers mechanism.
+   */
+  private static final class PPRPartialResponseWriter extends PartialResponseWriter 
+  {
+    public PPRPartialResponseWriter(ResponseWriter writer)
+    {
+      super(null);
+      assert(writer instanceof PPRResponseWriter);
+      _pprWriter = (PPRResponseWriter) writer;
+    }
+
+    @Override
+    public void endDocument() throws IOException
+    {
+      getWrapped().endDocument();
+    }
+
+    @Override
+    public ResponseWriter getWrapped()
+    {
+      return _pprWriter;
+    }
+
+    @Override
+    public void startDocument() throws IOException
+    {
+      getWrapped().startDocument();
+    }
+
+
+    @Override
+    public void endUpdate()
+      throws IOException
+    {
+      _pprWriter.endUpdate();
+    }
+    
+    @Override
+    public void startUpdate(String string) throws IOException 
+    {
+      _pprWriter.startUpdate(string);
+    }
+
+    private PPRResponseWriter _pprWriter;
+  }
+  
+  /**
+   * Callback for encoding subtrees during optimized PPR tree visits
+   */
+  private static final class ExecuteAllCallback implements VisitCallback
+  {
+    public ExecuteAllCallback(
+      FacesContext context, 
+      PhaseId phaseId)
+    {
+      _context= context;
+      _phaseId = phaseId;
+    }
+    
+    public VisitResult visit(VisitContext context, UIComponent target)
+    {
+
+      // For UIViewRoot it's important to return VisitResult.ACCEPT to indicate that the tree 
+      // visit start processing its children. This is also required to not get into a recursive 
+      // hell as we got here to begin from UIViewRoot.processDecodes()
+      if (target instanceof UIViewRoot)
+        return VisitResult.ACCEPT;
+
+      // we have the subtree we want, execute it
+      if (_phaseId == PhaseId.APPLY_REQUEST_VALUES) 
+      {
+        target.processDecodes(_context);
+      } 
+      else if (_phaseId == PhaseId.PROCESS_VALIDATIONS) 
+      {
+        target.processValidators(_context);
+      } 
+      else if (_phaseId == PhaseId.UPDATE_MODEL_VALUES) 
+      {
+        target.processUpdates(_context);
+      }        
+
+      // we have finished processing desired target
+      return VisitResult.REJECT;
+    }
+    
+    private FacesContext _context;
+    private PhaseId      _phaseId;
+  }  
+  
+  private Boolean _ajaxRequest;
+  private List<String> _executeIds;
+  private FacesContext _context = null; 
+  private Boolean _partialRequest;
+  private PartialResponseWriter _partialResponseWriter;
+  private boolean _released;
+  private Boolean _renderAll;
+  private Collection<String> _renderIds;
+
+  private static final Set<VisitHint> _EXECUTE_VISIT_HINTS = EnumSet.of(VisitHint.SKIP_UNRENDERED,
+                                                                        VisitHint.EXECUTE_LIFECYCLE);  
+  
+  private static final String _RESPONSE_CONTENT_TYPE = "text/xml";
+  private static final String _FACES_REQUEST = "Faces-Request";
+  private static final String _PARTIAL_AJAX = "partial/ajax";
+  private static final String _PARTIAL_PROCESS = "partial/process";
+
+}
diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java
index 5e1283a..1057cda 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java
@@ -143,11 +143,23 @@ public class CoreRenderKit extends RenderKitDecorator
     return "org.apache.myfaces.trinidad.core.desktop";
   }
 
+  /**
+   * Return <code>true</code> if the request header <code>Faces-Request</code> is present with the 
+   * value <code>partial/ajax</code>. Otherwise, return <code>false</code>.
+   * 
+   * @param ec the ExternalContext instance.
+   * @return
+   */
   static public boolean isAjaxRequest(ExternalContext ec)
   {
-    return "true".equals(ec.getRequestHeaderMap().get(_PPR_REQUEST_HEADER));
+    return _PARTIAL_AJAX.equals(ec.getRequestHeaderMap().get(_FACES_REQUEST_HEADER));
   }
 
+  /**
+   * TODO: Use JSF2.0 <code>Faces-Request</code> parameter.
+   * @param parameters
+   * @return
+   */
   static public boolean isPartialRequest(Map<String, String[]> parameters)
   {
     String[] array = parameters.get(_PPR_REQUEST_HEADER);
@@ -156,6 +168,11 @@ public class CoreRenderKit extends RenderKitDecorator
     return "true".equals(array[0]);
   }
 
+  /**
+   * TODO: Use JSF2.0 <code>Faces-Request</code> parameter.
+   * @param ec
+   * @return
+   */
   static public boolean isPartialRequest(ExternalContext ec)
   {
     // A partial request could be an AJAX request, or it could
@@ -803,6 +820,9 @@ public class CoreRenderKit extends RenderKitDecorator
   static private final String _SCRIPT_LIST_KEY =
     "org.apache.myfaces.trinidadinternal.renderkit.ScriptList";
   static private final String _PPR_REQUEST_HEADER = "Tr-XHR-Message";
+  private static final String _FACES_REQUEST_HEADER = "Faces-Request";
+  private static final String _PARTIAL_AJAX = "partial/ajax";
+
 
   static private final String _USE_DIALOG_POPUP_INIT_PARAM =
     "org.apache.myfaces.trinidad.ENABLE_LIGHTWEIGHT_DIALOGS";
diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java
index 439affd..56c4a71 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java
@@ -23,11 +23,13 @@ import java.io.IOException;
 import java.io.Writer;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import javax.faces.component.UIComponent;
 import javax.faces.context.ExternalContext;
 import javax.faces.context.FacesContext;
+import javax.faces.context.PartialResponseWriter;
 import javax.faces.context.ResponseWriter;
 
 import org.apache.myfaces.trinidad.context.PartialPageContext;
@@ -36,6 +38,7 @@ import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
 import org.apache.myfaces.trinidad.util.Service;
 
+import org.apache.myfaces.trinidadinternal.io.ResponseWriterDecorator;
 import org.apache.myfaces.trinidadinternal.renderkit.core.pages.GenericEntry;
 
 /**
@@ -48,7 +51,7 @@ import org.apache.myfaces.trinidadinternal.renderkit.core.pages.GenericEntry;
  * TODO: write out fragments only once we've detected the
  * ID, to avoid sending unnecessary fragments
  */
-public class PPRResponseWriter extends ScriptBufferingResponseWriter
+public class PPRResponseWriter extends ResponseWriterDecorator // ScriptBufferingResponseWriter
 {
   public PPRResponseWriter(ResponseWriter     out,
                            RenderingContext   rc)
@@ -68,7 +71,7 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
   PPRResponseWriter(ResponseWriter out,
                     PPRResponseWriter base)
   {
-    super(out, base);
+    super(out);
     // New XmlResponseWriter
     _xml        = new XmlResponseWriter(out, out.getCharacterEncoding());
     // But the rest of the state is shared
@@ -116,9 +119,10 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
     // Stick another PI indicating that this is a rich reponse
     // Used for an Iframe based communication channel, since it cannot 
     // read response headers
-    _xml.write("<?Tr-XHR-Response-Type ?>\n");
+    // TODO: Do we need this?
+    // _xml.write("<?Tr-XHR-Response-Type ?>\n");
 
-    _xml.startElement("content", null);
+    _xml.startElement(_ELEMENT_PARTIAL_RESPONSE, null);
     String viewId = _facesContext.getViewRoot().getViewId();
     // HACK: don't write out an "action" for PPR on a GenericEntry page
     // (basically entirely for the InlineDatePicker case)
@@ -132,8 +136,9 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
     }
 
     // TODO: Portlet support for PPR?
-
-    _xml.writeText(" ", null);
+    // TODO: PS - Not sure why this extra space is being written out, but this causes an 'malformed 
+    // XML error to be thrown by JSF 2 Ajax. Commented out the line.
+    // _xml.writeText(" ", null);
 
     _state.documentStarting = false;
   }
@@ -141,12 +146,13 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
   public void endDocument() throws IOException
   {
     // Write out any buffered <script src=""> or inline scripts
-    writeBufferedScripts();
+    // TODO: No need to write buffered scripts as we directly let script pass through
+    // writeBufferedScripts();
     
     // Write out all of the framework-level scripts
     writeFrameworkScripts();
-    
-    _xml.endElement("content");
+    _endChanges();
+    _xml.endElement(_ELEMENT_PARTIAL_RESPONSE);
     _xml.endDocument();
 
     // Force "inside target mode" - this is for Facelets,
@@ -311,9 +317,49 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
     return _xml;
   }
   
+  
+  public void endUpdate() throws IOException
+  {
+    super.flush();
+
+    if (_state._allowedUpdateStarted)
+    {
+      _xml.write("]]>");
+      _xml.endElement(_ELEMENT_CHANGES_UPDATE);
+      _xml.flush();
+      _state._allowedUpdateStarted = false;
+    }
+  }
+  
+ 
+  /**
+   * Starts an update element for non-PPR based content. For e.g., for rendering out the 
+   * "javax.faces.ViewState" id.
+   * @param id the id to use for the update element
+   */
+  public void startUpdate(String id) throws IOException 
+  {
+    if (id != null && _allowedIds.contains(id))
+    {
+      _startChanges();
+      
+      if (!_state._allowedUpdateStarted)
+      {
+        _state._allowedUpdateStarted = true;
+        _xml.startElement(_ELEMENT_CHANGES_UPDATE, null);
+        _xml.writeAttribute(_ATTRIBUTE_ID, id, null);
+        _xml.write("<![CDATA[");
+        _xml.flush();
+      }
+    }
+  }  
+
+  
   /*
    * Writes out buffered inline scripts and script libraries
    */
+  
+/*  
   protected void writeBufferedScripts() throws IOException
   {
     List<String> libraries = getBufferedLibraries();
@@ -332,17 +378,18 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
     {
       for (String script : scripts)
       {
-        _xml.startElement("script", null);
+        _xml.startElement(_ELEMENT_EVAL, null);
         _xml.write("<![CDATA[");
         _xml.write(script);
         _xml.write("]]>");
-        _xml.endElement("script");
+        _xml.endElement(_ELEMENT_EVAL);
       }
     }
 
     // Clear out any buffered scripts/libraries
     clearBufferedContents();
   }
+*/ 
   
   /*
    * Writes out framework-level scripts
@@ -391,7 +438,7 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
     if (tag != null)
     {
       super.flush();
-      tag.start(_state.pprContext, elementName);
+      tag.startUpdate(_state.pprContext, elementName);
     }
 
     _state.componentStack.add(tag);
@@ -405,7 +452,7 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
     componentStack.remove(pos);
 
     if (tag != null)
-      tag.finish(_state.pprContext, elementName);
+      tag.finishUpdate(_state.pprContext, elementName);
   }
 
   private boolean _isInsideTarget()
@@ -414,7 +461,8 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
     // a partial target subtree.  Otherwise, we discard all
     // output.
     return _state.forceInsideTarget ||
-           _state.pprContext.isInsidePartialTarget();
+           _state.pprContext.isInsidePartialTarget() ||
+           _state._allowedUpdateStarted;
            
   }
 
@@ -468,7 +516,24 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
     }
   }
 
+  private void _startChanges() throws IOException
+  {
+    if (!_state.changesStarted)
+    {
+      _xml.startElement(_ELEMENT_CHANGES, null);
+      _state.changesStarted = true;
+    }
+  }
 
+  private void _endChanges()
+    throws IOException
+  {
+    if (_state.changesStarted)
+    {
+      _xml.endElement("changes");
+      _state.changesStarted = false;
+    }
+  }
   //
   // Class representing PPR behavior associated with a tag.  The
   // base class simply tells PPR when it's working with a partial target
@@ -480,14 +545,16 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
       _id = id;
     }
 
-    public void start(
+    public void startUpdate(
       PartialPageContextImpl pprContext,
       String             elementName) throws IOException
     {
       if (_id != null)
       {
+        _startChanges();
         pprContext.pushRenderedPartialTarget(_id);
-        _xml.startElement("fragment",null);
+        _xml.startElement(_ELEMENT_CHANGES_UPDATE, null);
+        _xml.writeAttribute(_ATTRIBUTE_ID, _id, null);
         _xml.write("<![CDATA[");
         _xml.flush(); // NEW
 
@@ -501,7 +568,7 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
       }
     }
 
-    public void finish(
+    public void finishUpdate(
       PartialPageContextImpl pprContext,
       String             elementName) throws IOException
     {
@@ -520,7 +587,7 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
         PPRResponseWriter.super.flush();
       
         _xml.write("]]>");
-        _xml.endElement("fragment");
+        _xml.endElement(_ELEMENT_CHANGES_UPDATE);
         _xml.flush();
         
         pprContext.popRenderedPartialTarget();
@@ -567,11 +634,6 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
     private String _id;
   }
 
-  
-  private State _state;
-  private ResponseWriter _xml;
-  private final FacesContext _facesContext =
-   FacesContext.getCurrentInstance();
 
   static private class State
   {
@@ -585,9 +647,22 @@ public class PPRResponseWriter extends ScriptBufferingResponseWriter
     public int           elementDepth;
     public boolean       documentStarted;
     public boolean       documentStarting;
+    public boolean       changesStarted;
+    private boolean      _allowedUpdateStarted;
     public final List<PPRTag> componentStack = new ArrayList<PPRTag>(50);
     public final PartialPageContextImpl pprContext;
   }
 
+  private State _state;
+  private ResponseWriter _xml;
+  private final FacesContext _facesContext = FacesContext.getCurrentInstance();
+  
   static private final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(PPRResponseWriter.class);
+  private static final String _ELEMENT_PARTIAL_RESPONSE = "partial-response";
+  private static final String _ELEMENT_CHANGES = "changes";
+  private static final String _ELEMENT_CHANGES_UPDATE = "update";
+  private static final String _ELEMENT_EVAL = "eval";
+  private static final String _ATTRIBUTE_ID = "id";
+  private static final List<String> _allowedIds = Arrays.asList(PartialResponseWriter.VIEW_STATE_MARKER);
+
 }
diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java
index 58bc5c0..c178c4a 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java
@@ -75,7 +75,7 @@ public class CommandLinkRenderer extends GoLinkRenderer
       Map<String, String> parameterMap =
         context.getExternalContext().getRequestParameterMap();
 
-      Object source = parameterMap.get("source");
+      Object source = parameterMap.get("javax.faces.source");
       String clientId = component.getClientId(context);
 
       if ((source != null) && source.equals(clientId))
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
index 2a4537e..8c346a5 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
@@ -1701,7 +1701,8 @@ function submitForm(
   form,
   doValidate,
   parameters,
-  isPartial
+  isPartial, 
+  event
   )
 {
   // If we've delayed any sort of event submission, we won't want to do it at
@@ -1862,7 +1863,7 @@ function submitForm(
       }
       else
       {
-        TrPage.getInstance().sendPartialFormPost(form, parameters);
+        TrPage.getInstance().sendPartialFormPost(form, parameters, null, event);
       }
     }
     else
@@ -3868,7 +3869,8 @@ function _firePartialChange(url)
 function _submitPartialChange(
   form,
   doValidate,
-  parameters)
+  parameters,
+  event)
 {
   // If there's no PPR iframe, then just perform a normal,
   // full-page submission.
@@ -3886,10 +3888,10 @@ function _submitPartialChange(
   parameters = _addFormParameter(parameters, "partial", "true");
 
   // block all mouse clicks until the submit is done
-    _pprStartBlocking(window);
+  _pprStartBlocking(window);
 
   // Submit the form
-  var submitted = submitForm(form, doValidate, parameters, true);
+  var submitted = submitForm(form, doValidate, parameters, true, event);
 
   // If the form wasn't actually submitted, update the ref count
   if (!submitted)
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
index 0b902f7..9028b87 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
@@ -53,11 +53,22 @@ TrPage.prototype.getRequestQueue = function()
 TrPage.prototype.sendPartialFormPost = function(
   actionForm,
   params,
-  headerParams)
+  headerParams,
+  event)
 {
+  var source = "";
+  if (params != null)
+    source = params.source;
+
+  TrPage._delegateToJSFAjax(actionForm, source, event, params);
+
+
+  /** Delegating to jsf.ajax.request(). Do not call the Trinidad PPR request mechanism
+   
   this.getRequestQueue().sendFormPost(
     this, this._requestStatusChanged,
     actionForm, params, headerParams);
+  */
 }
 
 TrPage.prototype._requestStatusChanged = function(requestEvent)
@@ -746,9 +757,10 @@ TrPage._autoSubmit = function(formId, inputId, event, validateForm, params)
     if (event["type"] == "hidden")
       event = window.event;
   }
-
+  
   // If onchange is used for validation, then first validate 
   // just the current input
+
   var isValid = true;
   if (_TrEventBasedValidation)
     isValid = _validateInput(event, true);
@@ -761,6 +773,27 @@ TrPage._autoSubmit = function(formId, inputId, event, validateForm, params)
     params.event = "autosub";
     params.source = inputId;
   
-    _submitPartialChange(formId, validateForm, params);
+    _submitPartialChange(formId, validateForm, params, event);
   }
 }
+
+/**
+ * Causes a partial submit to occur on a given component using the jsf.ajax.request call. The 
+ * specified component will not be validated (yet).
+ * @param formId(String) Id of the form to partial submit.
+ * @param inputId(String) Id of the element causing the partial submit.  
+ * @param event(Event) The javascript event object.
+ * @param params(Object} additional parameters to send
+ */
+TrPage._delegateToJSFAjax = function(formId, inputId, event, params)
+{
+  var doc = window.document;
+  var source = _getElementById(doc, inputId);
+
+  if (!params)
+    params = {};
+
+  // TODO: add execute and render targets??
+  
+  jsf.ajax.request(source, event, params);
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.

[myfaces-trinidad] 10/10: Checkpoint

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch jsf2_ajax
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit ec528aa8c661b96ea5b63f42a9ab1b3b6230a754
Author: Andrew Robinson <ar...@apache.org>
AuthorDate: Mon Mar 22 21:58:18 2010 +0000

    Checkpoint
---
 .../trinidaddemo/PartialDemoStatusBean.java        |  28 +++-
 .../myfaces/trinidaddemo/PartialDemoUtilBean.java  |  42 ++++-
 .../src/main/webapp/components/inputFile.jspx      |   4 +-
 .../src/main/webapp/demos/ajaxPPRDemos.xhtml       |  27 ++-
 .../main/javascript/META-INF/adf/jsLibs/Page.js    | 184 +++++++++++++++------
 .../adf/jsLibs/xhr/IFrameXMLRequestEvent.js        |  77 ++++++---
 .../META-INF/adf/jsLibs/xhr/RequestQueue.js        |  90 +++++++---
 .../META-INF/adf/jsLibs/xhr/XMLRequestEvent.js     |  16 +-
 8 files changed, 365 insertions(+), 103 deletions(-)

diff --git a/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoStatusBean.java b/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoStatusBean.java
index 1e1fedf..efa1fbe 100644
--- a/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoStatusBean.java
+++ b/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoStatusBean.java
@@ -6,9 +6,9 @@
  *  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
@@ -22,6 +22,9 @@ import java.text.SimpleDateFormat;
 
 import java.util.Date;
 
+import org.apache.myfaces.trinidad.model.UploadedFile;
+
+
 public class PartialDemoStatusBean implements java.io.Serializable
 {
   public PartialDemoStatusBean()
@@ -144,6 +147,24 @@ public class PartialDemoStatusBean implements java.io.Serializable
     _checkBoxUpdateCount++;
   }
 
+  public String getUploadFileState()
+  {
+    return this._uploadFileState;
+  }
+
+  public void setUploadFile(UploadedFile file)
+  {
+    if (file == null)
+    {
+      this._uploadFileState = _DEFAULT_UPLOAD_FILE;
+    }
+    else
+    {
+      this._uploadFileState = String.format(
+        "Uploaded file %s (%d bytes)", file.getFilename(), file.getLength());
+    }
+  }
+
   public void reset()
   {
     resetCheckBox();
@@ -151,6 +172,7 @@ public class PartialDemoStatusBean implements java.io.Serializable
     _linkUpdate = _DEFAULT_LINK_UPDATE;
     _radioState = _DEFAULT_RADIO_STATE;
     _textValue = _DEFAULT_TEXT_VALUE;
+    _uploadFileState = _DEFAULT_UPLOAD_FILE;
   }
 
   private int     _checkBoxUpdateCount;
@@ -160,6 +182,7 @@ public class PartialDemoStatusBean implements java.io.Serializable
   private String  _linkUpdate;
   private String  _radioState;
   private String  _textValue;
+  private String  _uploadFileState;
 
   private static String _NOTHING              = "nothing yet.";
   private static String _DEFAULT_CHECK_STATE  = "updates this text.";
@@ -170,4 +193,5 @@ public class PartialDemoStatusBean implements java.io.Serializable
   private static String _DEFAULT_RADIO_STATE  = "no selection yet.";
   private static String _DEFAULT_TEXT_STATE   = _NOTHING;
   private static String _DEFAULT_TEXT_VALUE   = "Change this text";
+  private static String _DEFAULT_UPLOAD_FILE  = "No file was uploaded";
 }
diff --git a/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java b/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java
index b061f3b..1b50e4c 100644
--- a/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java
+++ b/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java
@@ -6,9 +6,9 @@
  *  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
@@ -27,6 +27,8 @@ import javax.faces.event.ValueChangeEvent;
 
 import org.apache.myfaces.trinidad.component.UIXOutput;
 import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidad.model.UploadedFile;
+
 
 public class PartialDemoUtilBean
 {
@@ -114,13 +116,38 @@ public class PartialDemoUtilBean
     Object newValue = vce.getNewValue();
     if ((newValue != null) && !"".equals(newValue))
     {
-      FacesContext fContext = FacesContext.getCurrentInstance(); 
-      ViewHandler vh = fContext.getApplication().getViewHandler(); 
-      UIViewRoot root = vh.createView(fContext, newValue.toString()); 
-      fContext.setViewRoot(root); 
+      FacesContext fContext = FacesContext.getCurrentInstance();
+      ViewHandler vh = fContext.getApplication().getViewHandler();
+      UIViewRoot root = vh.createView(fContext, newValue.toString());
+      fContext.setViewRoot(root);
     }
   }
 
+  public void setRenderInputFile(boolean renderInputFile)
+  {
+    this._renderInputFileTemp = renderInputFile;
+  }
+
+  public boolean isRenderInputFile()
+  {
+    Boolean value = (Boolean)
+      FacesContext.getCurrentInstance().getViewRoot().getViewMap().get(
+        _RENDER_INPUT_FILE_KEY);
+    return value != null && value;
+  }
+
+  public void fileUploaded(ValueChangeEvent event)
+  {
+    _status.setUploadFile((UploadedFile) event.getNewValue());
+  }
+
+  public void updateRenderInputFileState(ActionEvent event)
+  {
+    FacesContext.getCurrentInstance().getViewRoot().getViewMap().put(
+      _RENDER_INPUT_FILE_KEY, _renderInputFileTemp);
+    _renderInputFileTemp = null;
+  }
+
   private void _resetList()
   {
     _listUpdate.setValue("nothing yet.");
@@ -135,4 +162,7 @@ public class PartialDemoUtilBean
 
   private PartialDemoStatusBean _status;
   private UIXOutput _listUpdate;
+  private Boolean _renderInputFileTemp;
+  private final static String _RENDER_INPUT_FILE_KEY = PartialDemoUtilBean.class.getName() +
+                                                       ".renderInputFile";
 }
diff --git a/trinidad-examples/trinidad-demo/src/main/webapp/components/inputFile.jspx b/trinidad-examples/trinidad-demo/src/main/webapp/components/inputFile.jspx
index 53e70cd..486a10c 100644
--- a/trinidad-examples/trinidad-demo/src/main/webapp/components/inputFile.jspx
+++ b/trinidad-examples/trinidad-demo/src/main/webapp/components/inputFile.jspx
@@ -30,7 +30,7 @@
           <f:facet name="separator">
             <tr:separator/>
           </f:facet>
-          <tr:panelGroupLayout layout="horizontal">
+          <tr:panelGroupLayout layout="horizontal" partialTriggers="cb1">
             <tr:commandLink immediate="true" text="Component Guide" action="guide"/>
             <tr:spacer width="10"/>
             <tr:goLink destination="http://myfaces.apache.org/trinidad/trinidad-api/tagdoc/tr_inputFile.html"
@@ -39,7 +39,7 @@
           <tr:outputFormatted styleUsage="instruction" value="&lt;b>inputFile&lt;/b>"/>
           <tr:inputFile binding="#{editor.component}" label="Label"
                         valueChangeListener="#{ui.fileUploaded}"/>
-          <tr:commandButton text="Submit"/>
+          <tr:commandButton text="Submit" id="cb1" partialSubmit="true" />
           <jsp:directive.include file="editor.jspf"/>
         </tr:panelGroupLayout>
       </tr:form>
diff --git a/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml b/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
index fe9e8d4..00f360d 100644
--- a/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
+++ b/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
@@ -69,7 +69,7 @@ function setFocus(event)
         </trh:script>
       </tr:group>
     </f:facet>
-    <tr:form>
+    <tr:form usesUpload="#{partialDemoUtil.renderInputFile}" partialTriggers="ifsbc1">
       <tr:panelPage>
         <f:facet name="navigationGlobal">
           <tr:panelGroupLayout id="pgl1" layout="horizontal">
@@ -230,6 +230,31 @@ function setFocus(event)
                 <tr:statusIndicator id="si5" />
               </tr:panelGroupLayout>
             </tr:panelHeader>
+            <tr:panelHeader text="Input File / Multi-part form demonstration">
+              <tr:outputFormatted styleUsage="instruction"
+                                  value="This section will add a input file to the page so that a multi-part submission is made which will bypass the JSF 2 AJAX and fall back on Trinidad PPR code." />
+              <tr:panelGroupLayout id="ifpgl1" layout="horizontal">
+                <f:facet name="separator">
+                  <tr:spacer width="10" id="ifsp1"/>
+                </f:facet>
+                <tr:selectBooleanCheckbox id="ifsbc1" value="#{partialDemoUtil.renderInputFile}" />
+                <tr:commandButton id="ifcb1" text="Update the visibile status"
+                                  partialSubmit="true"
+                                  actionListener="#{partialDemoUtil.updateRenderInputFileState}" />
+                <tr:statusIndicator id="ifsi1" />
+              </tr:panelGroupLayout>
+
+              <tr:panelGroupLayout id="ifpgl2" layout="horizontal"
+                                   rendered="#{partialDemoUtil.renderInputFile}">
+                <tr:inputFile id="ifif1" valueChangeListener="#{partialDemoUtil.fileUploaded}"
+                              label="inputFile" />
+                <tr:commandButton id="ifcb2" text="Submit the file"
+                                  partialSubmit="true" />
+                <tr:outputFormatted id="ifof1" styleUsage="instruction"
+                                    value="#{partialDemoUtil.status.uploadFileState}"
+                                    partialTriggers="ifcb2" />
+              </tr:panelGroupLayout>
+            </tr:panelHeader>
           </tr:panelGroupLayout>
           <tr:panelLabelAndMessage id="plam1" label="Ajax Status Log">
             <tr:inputText id="it1" value="" simple="true" rows="7" columns="100" />
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
index 75764bb..ba28cca 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
@@ -18,13 +18,13 @@
  */
 function TrPage()
 {
-  if (typeof jsf != "undefined")
+  this._loadedLibraries = TrPage._collectLoadedLibraries();
+  this._requestQueue = new TrRequestQueue(window);
+
+  if (this._requestQueue.__useJsfBuiltInAjaxForXhr())
   {
     jsf.ajax.addOnEvent(TrUIUtils.createCallback(this, this._jsfAjaxCallback));
   }
-
-  this._loadedLibraries = TrPage._collectLoadedLibraries();
-  this._requestQueue = new TrRequestQueue(window);
 }
 
 /**
@@ -38,6 +38,38 @@ TrPage.getInstance = function()
   return TrPage._INSTANCE;
 }
 
+TrPage._MockXHR = function(requestEvent)
+{
+  this.UNSENT = 0;
+  this.OPENED = 1;
+  this.HEADERS_RECEIVED = 2;
+  this.LOADING = 3;
+  this.DONE = 4;
+  this.readyState = this.DONE;
+  this.status = requestEvent.getResponseStatusCode();
+  this.statusText = "";
+  this._requestEvent = requestEvent;
+  this.responseText = requestEvent.getResponseText();
+  this.responseXML = requestEvent.getResponseXML();
+}
+
+// Unsupported API methods that require a return value:
+TrPage._MockXHR.prototype.getResponseHeader = function(header)
+{
+  return this._requestEvent.getResponseHeader(header);
+}
+
+TrPage._MockXHR.prototype.getAllResponseHeaders = function()
+{
+  return this._requestEvent._getAllResponseHeaders();
+}
+
+// No-op API methods:
+TrPage._MockXHR.prototype.open =
+TrPage._MockXHR.prototype.setRequestHeader =
+TrPage._MockXHR.prototype.send =
+TrPage._MockXHR.prototype.abort = function () {};
+
 /**
  * Return the shared request queue for the page.
  */
@@ -97,7 +129,7 @@ TrPage.prototype._requestStatusChanged = function(requestEvent)
           }
           else
           {
-            this._handlePprResponse(responseDocument.documentElement);
+            this._handlePprResponse(requestEvent, responseDocument);
           }
         }
       }
@@ -169,11 +201,50 @@ TrPage.prototype._handleJsfAjaxResponse = function(requestEvent)
   }
 }
 
-TrPage.prototype._handlePprResponse = function(documentElement)
+/**
+ * Method to bridge compatibility between the Trinidad IFrame-PPR implementation
+ * an the JSF 2 AJAX javascript API
+ */
+TrPage.prototype._delegateResponseToJsfAjax = function(requestEvent, document)
 {
-  var rootNodeName = TrPage._getNodeName(documentElement);
+console.log("_delegateResponseToJsfAjax");
+  // We wish to have JSF 2 handle the response. In order to do that we need to
+  // construct the necessary parameters for the jsf.ajax.response method.
+  //
+  // The first parameter is the XHR object, so we must wrap the response in such
+  // a way that JSF 2 believes the data to be coming from an XHR object
+  //
+  var request = new TrPage._MockXHR(requestEvent);
+
+  // The second parameter is the context object which is the request context object
+  // containing the source element, onerror callback, and onevent callback.
+  var source = requestEvent.getSource();
+  if (source)
+  {
+    source = document.getElementById(source);
+  }
+  var context =
+  {
+    "onevent": null,
+    "onerror": null,
+    "source": source,
+    "formid": requestEvent.getFormId(),
+    "render": null
+  };
 
-  if (rootNodeName == "content")
+  jsf.ajax.response(request, context);
+}
+
+TrPage.prototype._handlePprResponse = function(requestEvent, document)
+{
+  if (this._requestQueue.__useJsfBuiltInAjaxForXhr())
+  {
+    return this._delegateResponseToJsfAjax(requestEvent, document);
+  }
+console.log("_handlePprResponse");
+  var documentElement = document.documentElement;
+  var rootNodeName = TrPage._getNodeName(documentElement);
+  if (rootNodeName == "partial-response")
   {
     // Update the form action
     this._handlePprResponseAction(documentElement);
@@ -184,41 +255,52 @@ TrPage.prototype._handlePprResponse = function(documentElement)
     for (var i = 0; i < length; i++)
     {
       var childNode = childNodes[i];
-      var childNodeName = TrPage._getNodeName(childNode);
 
-      if (childNodeName == "fragment")
-      {
-        this._handlePprResponseFragment(childNode);
-      }
-      else if (childNodeName == "script")
-      {
-        this._handlePprResponseScript(childNode);
-      }
-      else if (childNodeName == "script-library")
+      switch (TrPage._getNodeName(childNode))
       {
-        this._handlePprResponseLibrary(childNode);
+        case "changes":
+          for (var j = 0, size = childNode.childNodes.length; j < size; ++j)
+          {
+            var changeNode = childNode.childNodes[j];
+            switch (TrPage._getNodeName(changeNode))
+            {
+              case "update":
+                this._handlePprResponseFragment(changeNode);
+                break;
+
+              case "eval":
+                this._handlePprResponseScript(changeNode);
+                break;
+
+              case "extension":
+                for (var k = 0, extsize = changeNode.childNodes.length; k < extsize; ++k)
+                {
+                  if (changeNode.childNodes[k].nodeName == "script-library")
+                  {
+                    this._handlePprResponseLibrary(changeNode.childNodes[k]);
+                  }
+                }
+                break;
+
+              // Do not support the new updates with the Trinidad legacy fallback code:
+              default: break;
+            }
+          }
+          break;
+        case "error":
+          var nodeText = TrPage._getTextContent(childNode.nextSibling.firstChild);
+          // This should not happen - there should always be an error message
+          if (nodeText == null)
+            nodeText = "Unknown error during PPR";
+          alert(nodeText);
+          return;
+        case "redirect":
+          var url = TrPage._getTextContent(childNode);
+          // TODO: fix for portlets???
+          window.location.href = url;
       }
     }
   }
-  else if (rootNodeName == "redirect")
-  {
-    var url = TrPage._getTextContent(documentElement);
-    // TODO: fix for portlets???
-    window.location.href = url;
-  }
-  else if (rootNodeName == "error")
-  {
-    var nodeText = TrPage._getTextContent(documentElement);
-    // This should not happen - there should always be an error
-    // message
-    if (nodeText == null)
-      nodeText = "Unknown error during PPR";
-    alert(nodeText);
-  }
-  else if (rootNodeName == "noop")
-  {
-    // No op
-  }
   else
   {
     // FIXME: log an error
@@ -380,7 +462,11 @@ TrPage.prototype._handlePprResponseFragment = function(fragmentNode)
     if (!firstFragmenChildNode)
        return;
 
-    var outerHTML = firstFragmenChildNode.data;
+    var outerHTML = "";
+    for (var i = 0, size = fragmentNode.childNodes.length; i < size; ++i)
+    {
+      outerHTML += fragmentNode.childNodes[i].data;
+    }
 
     // Windows Mobile 6 requires the element to be a child of
     // document.body to allow setting its innerHTML property.
@@ -519,15 +605,17 @@ TrPage.prototype._getFirstElementFromFragment = function(fragmentNode)
 {
   // Fragment nodes contain a single CDATA section
   var fragmentChildNodes = fragmentNode.childNodes;
-  // assert((fragmentChildNodes.length == 1), "invalid fragment child count");
-
-  var cdataNode = fragmentNode.childNodes[0];
-  // assert((cdataNode.nodeType == 4), "invalid fragment content");
-  // assert(cdataNode.data, "null fragment content");
 
-  // The new HTML content is in the CDATA section.
-  // TODO: Is CDATA content ever split across multiple nodes?
-  var outerHTML = cdataNode.data;
+  // assert((fragmentChildNodes.length == 0), "invalid fragment child count");
+  var outerHTML = "";
+  for (var i = 0, size = fragmentChildNodes.length; i < size; ++i)
+  {
+    // The new HTML content is in the CDATA section.
+    if (fragmentChildNodes[i].nodeType == 4)
+    {
+      outerHTML += fragmentChildNodes[i].data;
+    }
+  }
 
   // We get our html node by slamming the fragment contents into a div.
   var doc = window.document;
@@ -537,14 +625,12 @@ TrPage.prototype._getFirstElementFromFragment = function(fragmentNode)
   div.innerHTML = outerHTML;
 
   return TrPage._getFirstElementWithId(div);
-
 }
 
 // Returns the first element underneath the specified dom node
 // which has an id.
 TrPage._getFirstElementWithId = function(domNode)
 {
-
   var childNodes = domNode.childNodes;
   var length = childNodes.length;
 
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/IFrameXMLRequestEvent.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/IFrameXMLRequestEvent.js
index 69e9632..a125b61 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/IFrameXMLRequestEvent.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/IFrameXMLRequestEvent.js
@@ -6,9 +6,9 @@
  *  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
@@ -19,16 +19,29 @@
 
 /**
  * Iframe base Data Transfer Request Event class. This object is passed back to the listeners
- * of a Data Transfer Service Request. This object and TrXMLRequestEvent 
+ * of a Data Transfer Service Request. This object and TrXMLRequestEvent
  * support ITrXMLRequestEvent pseudo-interface
  * @ see TrXMLRequestEvent
  */
 function TrIFrameXMLRequestEvent(
-  iframeDoc)
+  iframeDoc,
+  source,
+  formId)
 {
   this._iframeDoc = iframeDoc;
+  this._source = source;
+  this._formId = formId;
 }
 
+TrIFrameXMLRequestEvent.prototype.getSource = function()
+{
+  return this._source;
+}
+
+TrIFrameXMLRequestEvent.prototype.getFormId = function()
+{
+  return this._formId;
+}
 
 TrIFrameXMLRequestEvent.prototype.getStatus = function()
 {
@@ -57,17 +70,30 @@ TrIFrameXMLRequestEvent.prototype.getResponseXML = function()
 * NOTE: this method is valid only for TrXMLRequestEvent.STATUS_COMPLETE
 **/
 TrIFrameXMLRequestEvent.prototype.getResponseText = function()
-{  
+{
   var agentIsIE = _agent.isIE;
   var iframeDoc = this._iframeDoc, xmlDocument = null;
 
   if(agentIsIE && iframeDoc.XMLDocument)
     xmlDocument = iframeDoc.XMLDocument;
-  else if(window.XMLDocument && (iframeDoc instanceof XMLDocument))
+  else if (window.XMLDocument && this._isResponseValidXML())
     xmlDocument = iframeDoc;
-    
+
   if(xmlDocument)
-    return AdfAgent.AGENT.getNodeXml(xmlDocument);
+  {
+    if (typeof XMLSerializer != "undefined")
+    {
+      return (new XMLSerializer()).serializeToString(xmlDocument);
+    }
+    else if (agentIsIE)
+    {
+      return xmlDocument.xml;
+    }
+  else
+    {
+      return null;
+    }
+  }
   else
     return iframeDoc.documentElement.innerHTML;
 }
@@ -81,6 +107,8 @@ TrIFrameXMLRequestEvent.prototype._isResponseValidXML = function()
     return true;
   else if(window.XMLDocument && (iframeDoc instanceof XMLDocument))
     return true;
+  else if (_agent.isSafari && iframeDoc.xmlVersion != null)
+    return true;
   else
     return false;
 }
@@ -96,30 +124,31 @@ TrIFrameXMLRequestEvent.prototype.getResponseStatusCode = function()
 }
 
 /**
-* Returns if whether if is a rich response
+* Returns if whether if is a PPR response
 * NOTE: this method is valid only for TrXMLRequestEvent.STATUS_COMPLETE
 **/
 TrIFrameXMLRequestEvent.prototype.isPprResponse = function()
 {
   var agentIsIE = _agent.isIE;
   var iframeDoc = this._iframeDoc;
-  var isRichReponse = false;
-  
-  // Look for "Adf-Rich-Response-Type" PI
+  var pprResponse = false;
+
+  // Look for "Tr-XHR-Response-Type" PI
   if(agentIsIE && iframeDoc.XMLDocument)
   {
     var xmlDocument = iframeDoc.XMLDocument, childNodes = xmlDocument.childNodes;
+    console.log(xmlDocument);
     // In IE the xml PI is the first node
-    if(childNodes.length >= 2 && childNodes[1].nodeName ==  "Tr-XHR-Response-Type")
-      isRichReponse = true;
+    if(childNodes.length >= 2 && childNodes[1].nodeName ==  "partial-response")
+      pprResponse = true;
   }
   else
   {
-    if(iframeDoc.firstChild && iframeDoc.firstChild.nodeName ==  "Tr-XHR-Response-Type")
-      isRichReponse = true;
+    if(iframeDoc.firstChild && iframeDoc.firstChild.nodeName ==  "partial-response")
+      pprResponse = true;
   }
-  
-  return isRichReponse;
+
+  return pprResponse;
 }
 
 /**
@@ -130,6 +159,14 @@ TrIFrameXMLRequestEvent.prototype.getResponseContentType = function()
 {
   if(this._isResponseValidXML())
     return "text/xml";
-    
+
   return "text/html";
-}
\ No newline at end of file
+}
+
+/**
+ * Returns if the request was made by the built in JSF AJAX APIs
+ */
+TrIFrameXMLRequestEvent.prototype.isJsfAjaxRequest = function()
+{
+  return false;
+};
\ No newline at end of file
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
index ff57d71..3678c23 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
@@ -61,7 +61,9 @@ TrRequestQueue._RequestItem = function(
   headerParams,
   content,
   method,
-  event
+  event,
+  source,
+  formId
   )
 {
   this._type = type;
@@ -71,6 +73,8 @@ TrRequestQueue._RequestItem = function(
   this._content = content;
   this._method = method;
   this._event = event;
+  this._source = source;
+  this._formId = formId;
 }
 
 TrRequestQueue.prototype._broadcastRequestStatusChanged = function(
@@ -98,11 +102,14 @@ TrRequestQueue.prototype._addRequestToQueue = function(
   actionURL,
   content,
   headerParams,
-  event
+  event,
+  source,
+  formId
   )
 {
   var newRequest = new TrRequestQueue._RequestItem(
-                          type, context, actionURL, headerParams, content, listener, event);
+                          type, context, actionURL, headerParams, content,
+                          listener, event, source, formId);
 
   if (this._useJsfBuiltInAjaxForXhr && type == TrRequestQueue._XMLHTTP_TYPE)
   {
@@ -120,7 +127,8 @@ TrRequestQueue.prototype._addRequestToQueue = function(
   {
     var dtsRequestEvent = new TrXMLRequestEvent(
                     TrXMLRequestEvent.STATUS_QUEUED,
-                    null); // no xmlhttp object at this time
+                    null, // no xmlhttp object at this time
+                    source);
 
     this._broadcastRequestStatusChanged(context, listener, dtsRequestEvent);
   }
@@ -163,10 +171,8 @@ TrRequestQueue.prototype.sendFormPost = function(
   {
     pprURL = actionForm.getAttribute("_trinPPRAction");
   }
-  catch (e)
-  {
-  }
-  var action = pprURL?pprURL:actionForm.action;
+  catch (e) { ; }
+  var action = pprURL ? pprURL : actionForm.action;
 
   if (this._isMultipartForm(actionForm))
   {
@@ -187,12 +193,14 @@ TrRequestQueue.prototype.sendFormPost = function(
       // gather the form values
       // TODO: log a warning if we're dropping any headers?  Or
       // come up with a hack to send "headers" via a multipart request?
-      this.sendRequest(context, method, action, params, headerParams, event);
+      this.sendRequest(context, method, action, params, headerParams, event,
+        params ? params.source : null, actionForm.id);
     }
     else
     {
       var content = this._getPostbackContent(actionForm, params);
-      this.sendRequest(context, method, action, content, headerParams, event);
+      this.sendRequest(context, method, action, content, headerParams, event,
+        params ? params.source : null, actionForm.id);
     }
   }
 }
@@ -385,6 +393,8 @@ TrRequestQueue._appendUrlFormEncoded = function(
 * @param headerParams Option HTTP header parameters to attach to the request
 * @param content The content of the Asynchronous XML HTTP Post
 * @param event The browser event that triggered the request, if any
+* @param source The ID of the source element for the request
+* @param formId The ID of the form element
 */
 TrRequestQueue.prototype.sendRequest = function(
   context,
@@ -392,11 +402,13 @@ TrRequestQueue.prototype.sendRequest = function(
   actionURL,
   content,
   headerParams,
-  event
+  event,
+  source,
+  formId
   )
 {
   this._addRequestToQueue(TrRequestQueue._XMLHTTP_TYPE, context, method, actionURL, content,
-    headerParams, event);
+    headerParams, event, source, formId);
 }
 
 /**
@@ -420,10 +432,10 @@ TrRequestQueue.prototype.sendMultipartRequest = function(
   var privateContext =
      {"htmlForm":htmlForm, "params": params, "context": context, "method": method};
 
-  this._addRequestToQueue(TrRequestQueue._MULTIPART_TYPE, privateContext, null, actionURL);
+  this._addRequestToQueue(TrRequestQueue._MULTIPART_TYPE, privateContext, null, actionURL,
+    params ? params.source : null, htmlForm.id);
 }
 
-
 TrRequestQueue.prototype._doRequest = function()
 {
   // currently we are posting only one request at a time. In future we may batch
@@ -455,6 +467,9 @@ TrRequestQueue.prototype._doXmlHttpRequest = function(requestItem)
 
   xmlHttp.__dtsRequestContext = requestItem._context;
   xmlHttp.__dtsRequestMethod = requestItem._method;
+  xmlHttp.__dtsRequestSource = requestItem._source;
+  xmlHttp.__dtsRequestFormId = requestItem._formId;
+
   var callback = TrUIUtils.createCallback(this, this._handleRequestCallback);
   xmlHttp.setCallback(callback);
 
@@ -532,9 +547,12 @@ TrRequestQueue.prototype._doRequestThroughIframe = function(requestItem)
     iframeDoc.removeChild(iframeDoc.firstChild);
 
   // store our context variables for later use
+  this._source = requestItem.params ?
+    requestItem.params["javax.faces.source"] : null;
   this._dtsContext = requestItem._context.context;
   this._dtsRequestMethod = requestItem._context.method;
   this._htmlForm = htmlForm;
+  this._dtsSource = requestItem._source;
   this._savedActionUrl = htmlForm.action;
   this._savedTarget = htmlForm.target;
 
@@ -547,14 +565,20 @@ TrRequestQueue.prototype._doRequestThroughIframe = function(requestItem)
   htmlForm.target = frameName;
 
   this._appendParamNode(domDocument, htmlForm, "Tr-XHR-Message", "true");
-  // FIXME: the "partial" parameter is unnecessary
-  this._appendParamNode(domDocument, htmlForm, "partial", "true");
+  this._appendParamNode(domDocument, htmlForm, "javax.faces.partial.ajax", "true");
 
   if(params)
   {
+    if (params.source)
+    {
+      // Translate to JSF 2 payload
+      params["javax.faces.source"] = params.source;
+      delete params.source;
+    }
     for (var key in params)
     {
-      this._appendParamNode(domDocument, htmlForm, key, params[key]);
+      var paramValue = params[key];
+      this._appendParamNode(domDocument, htmlForm, key, paramValue);
     }
   }
 
@@ -631,6 +655,14 @@ TrRequestQueue.prototype._clearParamNodes = function()
   }
 }
 
+TrRequestQueue.prototype._isIFrameBlankHTML = function(iframeDoc)
+{
+  // In webkit browsers, the iframe load first with blank.html and will cause the
+  // code to incorrectly think the document is loaded when it is just the blank.html and
+  // the IFrame is still loading
+  return (_agent.isSafari && iframeDoc.documentURI == "about:blank");
+}
+
 TrRequestQueue.prototype._handleIFrameLoad = function()
 {
   var domDocument = this._getDomDocument();
@@ -651,7 +683,8 @@ TrRequestQueue.prototype._handleIFrameLoad = function()
   try
   {
     if(!iframeDoc.documentElement || !iframeDoc.documentElement.firstChild
-      || (agentIsIE && iframeDoc.readyState != "complete"))
+      || (agentIsIE && iframeDoc.readyState != "complete") ||
+      this._isIFrameBlankHTML(iframeDoc))
     {
       this._window.setTimeout(this._iframeLoadCallback, 50);
     }
@@ -679,7 +712,9 @@ TrRequestQueue.prototype._onIFrameLoadComplete = function(
   try
   {
     var dtsRequestEvent = new TrIFrameXMLRequestEvent(
-                              iframeDoc);
+                              iframeDoc,
+                              this._dtsSource,
+                              this._htmlForm.id);
 
     this._broadcastRequestStatusChanged(context, requestMethod,dtsRequestEvent);
   }
@@ -690,6 +725,7 @@ TrRequestQueue.prototype._onIFrameLoadComplete = function(
       iframeDoc.removeChild(iframeDoc.firstChild);
     this._htmlForm.action = this._savedActionUrl;
     this._htmlForm.target = this._savedTarget;
+    delete this._dtsSource;
     //clear the parameter nodes
     this._clearParamNodes();
     this._requestDone();
@@ -719,7 +755,7 @@ TrRequestQueue.prototype._handleRequestCallback = function(
     // the Http connection  has been closed
   }
 
-  if ((status < 200 || status >= 300) && (statusCode != 0))
+  if ((statusCode < 200 || statusCode >= 300) && (statusCode != 0))
   {
     TrRequestQueue._alertError();
     TrRequestQueue._logError("Error StatusCode(",
@@ -734,7 +770,9 @@ TrRequestQueue.prototype._handleRequestCallback = function(
     {
       var dtsRequestEvent = new TrXMLRequestEvent(
                   TrXMLRequestEvent.STATUS_COMPLETE,
-                  xmlHttp);
+                  xmlHttp,
+                  xmlHttp.__dtsRequestSource,
+                  xmlHttp.__dtsRequestFormId);
       this._broadcastRequestStatusChanged(
         xmlHttp.__dtsRequestContext,
         xmlHttp.__dtsRequestMethod,
@@ -840,6 +878,11 @@ TrRequestQueue.prototype.getDTSState = function()
   return this._state;
 }
 
+TrRequestQueue.prototype.__useJsfBuiltInAjaxForXhr = function()
+{
+  return this._useJsfBuiltInAjaxForXhr;
+}
+
 /**
  * broadcast the state change of the request queue to its listeners
  */
@@ -905,6 +948,9 @@ TrRequestQueue._logWarning = function(varArgs)
 TrRequestQueue._logError = function(varArgs)
 {
   if (window.console && console.error)
+  {
     console.error(arguments);
+  }
+
   // else???
-}
+}
\ No newline at end of file
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js
index ed669d9..4a8fbed 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js
@@ -25,11 +25,15 @@
  */
 function TrXMLRequestEvent(
   status,
-  request
+  request,
+  source,
+  formId
   )
 {
   this._status = status;
   this._request = request;
+  this._source = source;
+  this._formId = formId;
 }
 
 TrXMLRequestEvent.STATUS_QUEUED = 1;
@@ -37,11 +41,21 @@ TrXMLRequestEvent.STATUS_SEND_BEFORE = 2;
 TrXMLRequestEvent.STATUS_SEND_AFTER = 3;
 TrXMLRequestEvent.STATUS_COMPLETE = 4;
 
+TrXMLRequestEvent.prototype.getFormId = function()
+{
+  return this._formId;
+}
+
 TrXMLRequestEvent.prototype.getStatus = function()
 {
   return this._status;
 }
 
+TrXMLRequestEvent.prototype.getSource = function()
+{
+  return this._source;
+}
+
 /**
 * Returns the response of the AJAX Request as an XML document
 * NOTE: this method is valid only for TrXMLRequestEvent.STATUS_COMPLETE

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.

[myfaces-trinidad] 04/10: Add unblocking code

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch jsf2_ajax
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit 73959a8ae941ef9ec7eaeaf27165f030531cc6d8
Author: Andrew Robinson <ar...@apache.org>
AuthorDate: Wed Feb 10 16:50:57 2010 +0000

    Add unblocking code
---
 .../{ajaxPPRDemos.jspx => ajaxPPRDemos.xhtml}      | 61 +++++++-------
 .../main/javascript/META-INF/adf/jsLibs/Core.js    |  3 +-
 .../main/javascript/META-INF/adf/jsLibs/Page.js    | 93 +++++++++++++---------
 3 files changed, 85 insertions(+), 72 deletions(-)

diff --git a/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.jspx b/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
similarity index 91%
rename from trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.jspx
rename to trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
index 9fb3ad4..46696ce 100644
--- a/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.jspx
+++ b/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
@@ -16,15 +16,15 @@
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations
     under the License.
-	   
+
 -->
-<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
-          xmlns:f="http://java.sun.com/jsf/core"
-          xmlns:h="http://java.sun.com/jsf/html"
-          xmlns:trh="http://myfaces.apache.org/trinidad/html"
-          xmlns:tr="http://myfaces.apache.org/trinidad">
- <jsp:directive.page contentType="text/html;charset=utf-8"/>
- <f:view>
+<ui:composition
+  xmlns:ui="http://java.sun.com/jsf/facelets"
+  xmlns:h="http://java.sun.com/jsf/html"
+  xmlns:f="http://java.sun.com/jsf/core"
+  xmlns:tr="http://myfaces.apache.org/trinidad"
+  xmlns:trd="http://myfaces.apache.org/trinidad/demo"
+  xmlns:trh="http://myfaces.apache.org/trinidad/html">
   <h:outputScript name="jsf.js" library="javax.faces" target="body" id="os"/>
   <tr:document title="Partial Page Rendering Demos">
     <tr:form>
@@ -40,7 +40,7 @@
 
       <tr:panelHeader text="Welcome to the Apache Trinidad Partial Page Rendering Demos for JSF 2.0 Ajax">
         <tr:outputFormatted styleUsage="instruction" id="of0"
-                            value="These demos test Trinidad PPR with JSF 2.0 Ajax using both 
+                            value="These demos test Trinidad PPR with JSF 2.0 Ajax using both
                             trinidad and JSF components."/>
         <tr:panelGroupLayout layout="vertical">
           <f:facet name="separator">
@@ -49,8 +49,8 @@
           <tr:panelHeader text="Command components using JSF 2.0 native Ajax support" id="phCmd">
             <tr:outputFormatted styleUsage="instruction" id="of10"
                                 value="Tests commandButton components wired to use either Ajax JS API
-                                by itself or both JSF 2 Ajax and trinidad PPR. Clicking these buttons 
-                                should cause a partial or a full page submit (without errors) and 
+                                by itself or both JSF 2 Ajax and trinidad PPR. Clicking these buttons
+                                should cause a partial or a full page submit (without errors) and
                                 update the field on the right."/>
             <tr:spacer height="10" id="sp10"/>
             <tr:panelGroupLayout layout="horizontal" id="pgl10">
@@ -58,7 +58,7 @@
                 <f:facet name="separator">
                   <tr:spacer height="6" id="sp11"/>
                 </f:facet>
-                <tr:outputFormatted styleUsage="instruction" value="tr:commandButton using 
+                <tr:outputFormatted styleUsage="instruction" value="tr:commandButton using
                     jsf.ajax.request and partialSubmit=true." id="of11"/>
                 <tr:commandButton id="axBtn1"
                                 partialSubmit="true"
@@ -66,21 +66,21 @@
                                 shortDesc="partialSubmit"
                                 actionListener="#{partialDemoUtil.action}"/>
                   <!--f:ajax event="action" render=""/-->
-                <tr:outputFormatted styleUsage="instruction" value="tr:commandButton using jsf.ajax.request." 
+                <tr:outputFormatted styleUsage="instruction" value="tr:commandButton using jsf.ajax.request."
                  id="of12"/>
                 <tr:commandButton id="axBtn2"
                                   text="Full Submit"
                                   shortDesc="fullSubmit"
                                   actionListener="#{partialDemoUtil.action}"/>
-                
-                <tr:outputFormatted styleUsage="instruction" value="h:commandButton using jsf.ajax.request." 
+
+                <tr:outputFormatted styleUsage="instruction" value="h:commandButton using jsf.ajax.request."
                  id="of13"/>
-                
-                
+
+
               </tr:panelGroupLayout>
-              
+
               <tr:spacer width="30" height="10" id="sp12"/>
-             
+
               <tr:panelGroupLayout id="pgl12">
                 <tr:panelLabelAndMessage label="Button Clicked: " id="plm10">
                   <tr:outputFormatted id="btnTarget"
@@ -93,10 +93,10 @@
              </tr:panelGroupLayout>
            </tr:panelGroupLayout>
          </tr:panelHeader>
-       
+
          <tr:panelHeader text="InputText Component using JSF 2.0 Ajax" id="phInput">
            <tr:outputFormatted styleUsage="instruction"
-                             value="Tests autoSubmitting text fields which is also wired to use JSF 
+                             value="Tests autoSubmitting text fields which is also wired to use JSF
                              2.0 Ajax."/>
             <tr:panelGroupLayout layout="horizontal" id="pgl20">
               <f:facet name="separator">
@@ -114,14 +114,14 @@
                               label="Enter text and tab out: "
                               valueChangeListener="#{partialDemoUtil.valueChanged}"/>
                 <tr:outputFormatted styleUsage="instruction" value="tr:inputText with
-                    autoSubmit=true inside a subform" id="of21"/>                
+                    autoSubmit=true inside a subform" id="of21"/>
                 <tr:subform id="sf20">
                   <tr:inputText autoSubmit="true" id="itxt2" label="Enter a different text and tab out: "
                                  value="#{partialDemoUtil.status.textValue}"
                                  valueChangeListener="#{partialDemoUtil.valueChanged}"/>
                 </tr:subform>
               </tr:panelGroupLayout>
-              
+
               <tr:panelLabelAndMessage label="Input entered: ">
                <tr:outputFormatted id="itTarget"
                                    partialTriggers="itxt1 ::sf20:itxt2"
@@ -130,11 +130,11 @@
               </tr:panelLabelAndMessage>
             </tr:panelGroupLayout>
          </tr:panelHeader>
-         
+
          <tr:panelHeader text="Radio Buttons">
            <tr:outputFormatted styleUsage="instruction"
-                               value="This demo shows a two sets of radio buttons which use autoSubmit. 
-                               There is also an output component which is listening on updates to the 
+                               value="This demo shows a two sets of radio buttons which use autoSubmit.
+                               There is also an output component which is listening on updates to the
                                radio buttons and displaying status text accordingly."/>
           <tr:panelGroupLayout layout="horizontal">
            <tr:panelGroupLayout layout="vertical">
@@ -184,15 +184,14 @@
             </tr:outputFormatted>
            </tr:panelLabelAndMessage>
           </tr:panelGroupLayout>
-         </tr:panelHeader>         
+         </tr:panelHeader>
 
 
       </tr:panelGroupLayout>
      </tr:panelHeader>
      </tr:panelPage>
-     
+
     </tr:form>
-  
+
   </tr:document>
- </f:view>
-</jsp:root>
+</ui:composition>
\ No newline at end of file
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
index 8c346a5..ab82e87 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
@@ -1701,7 +1701,7 @@ function submitForm(
   form,
   doValidate,
   parameters,
-  isPartial, 
+  isPartial,
   event
   )
 {
@@ -3637,7 +3637,6 @@ function _doPprStartBlocking (win)
 //
 function _pprStopBlocking(win)
 {
-
   // No blocking is performed on Nokia, PPC and BlackBerry devices
   if (_agent.isPIE || _agent.isNokiaPhone || _agent.isBlackBerry)
     return;
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
index 9028b87..b9fb298 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
@@ -6,9 +6,9 @@
  *  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
@@ -18,6 +18,9 @@
  */
 function TrPage()
 {
+  jsf.ajax.addOnError(TrUIUtils.createCallback(this, this._jsfAjaxErrorCallback));
+  jsf.ajax.addOnEvent(TrUIUtils.createCallback(this, this._jsfAjaxCallback));
+
   this._loadedLibraries = TrPage._collectLoadedLibraries();
   this._requestQueue = new TrRequestQueue(window);
 }
@@ -47,7 +50,7 @@ TrPage.prototype.getRequestQueue = function()
  * posts and, for multipart/form posts, IFRAME-based transmission.
  * @param actionForm{FormElement} the HTML form to post
  * @param params{Object} additional parameters to send
- * @param headerParams{Object} HTTP headers to include (ignored if 
+ * @param headerParams{Object} HTTP headers to include (ignored if
  *   the request must be a multipart/form post)
  */
 TrPage.prototype.sendPartialFormPost = function(
@@ -64,7 +67,7 @@ TrPage.prototype.sendPartialFormPost = function(
 
 
   /** Delegating to jsf.ajax.request(). Do not call the Trinidad PPR request mechanism
-   
+
   this.getRequestQueue().sendFormPost(
     this, this._requestStatusChanged,
     actionForm, params, headerParams);
@@ -76,7 +79,7 @@ TrPage.prototype._requestStatusChanged = function(requestEvent)
   if (requestEvent.getStatus() == TrXMLRequestEvent.STATUS_COMPLETE)
   {
     var statusCode = requestEvent.getResponseStatusCode();
-    
+
     // The server might not return successfully, for example if an
     // exception is thrown.  When that happens, a non-200 (OK) status
     // code is returned as part of the HTTP prototcol.
@@ -119,7 +122,7 @@ TrPage.prototype._requestStatusChanged = function(requestEvent)
 TrPage.prototype._handlePprResponse = function(documentElement)
 {
   var rootNodeName = TrPage._getNodeName(documentElement);
-  
+
   if (rootNodeName == "content")
   {
     // Update the form action
@@ -127,15 +130,15 @@ TrPage.prototype._handlePprResponse = function(documentElement)
 
     var childNodes = documentElement.childNodes;
     var length = childNodes.length;
-    
+
     for (var i = 0; i < length; i++)
     {
       var childNode = childNodes[i];
       var childNodeName = TrPage._getNodeName(childNode);
-      
+
       if (childNodeName == "fragment")
-      {     
-        this._handlePprResponseFragment(childNode);  
+      {
+        this._handlePprResponseFragment(childNode);
       }
       else if (childNodeName == "script")
       {
@@ -161,7 +164,7 @@ TrPage.prototype._handlePprResponse = function(documentElement)
     if (nodeText == null)
       nodeText = "Unknown error during PPR";
     alert(nodeText);
-  }  
+  }
   else if (rootNodeName == "noop")
   {
     // No op
@@ -274,7 +277,7 @@ TrPage.prototype._resetForm = function(form)
     if (eval(trueResetCallback))
       doReload = true;
   }
-  
+
   return doReload;
 }
 
@@ -295,11 +298,11 @@ TrPage.prototype._handlePprResponseAction = function(contentNode)
 
   if (action)
   {
-    var doc = window.document;    
+    var doc = window.document;
 
     // Replace the form action used by the next postback
     // Particularly important for PageFlowScope which might
-    // change value of the pageflow scope token url parameter.    
+    // change value of the pageflow scope token url parameter.
     // TODO: track submitted form name at client, instead of
     // just updating the first form
     doc.forms[0].action = action;
@@ -444,14 +447,14 @@ TrPage._isDomAncestorOf = function(child, parent)
       break;
     child = parentOfChild;
   }
-  
+
   return false;
 }
 
 
 /**
- * Replaces the a dom element contained in a peer. 
- * 
+ * Replaces the a dom element contained in a peer.
+ *
  * @param newElement{DOMElement} the new dom element
  * @param oldElement{DOMElement} the old dom element
  */
@@ -459,8 +462,8 @@ TrPage.prototype.__replaceDomElement = function(newElement, oldElement)
 {
   oldElement.parentNode.replaceChild(newElement, oldElement);
 }
-  
-// Extracts the text contents from a rich response fragment node and 
+
+// Extracts the text contents from a rich response fragment node and
 // creates an HTML element for the first element that is found.
 TrPage.prototype._getFirstElementFromFragment = function(fragmentNode)
 {
@@ -477,14 +480,14 @@ TrPage.prototype._getFirstElementFromFragment = function(fragmentNode)
   var outerHTML = cdataNode.data;
 
   // We get our html node by slamming the fragment contents into a div.
-  var doc = window.document;  
+  var doc = window.document;
   var div = doc.createElement("div");
 
   // Slam the new HTML content into the div to create DOM
   div.innerHTML = outerHTML;
-  
+
   return TrPage._getFirstElementWithId(div);
-  
+
 }
 
 // Returns the first element underneath the specified dom node
@@ -494,7 +497,7 @@ TrPage._getFirstElementWithId = function(domNode)
 
   var childNodes = domNode.childNodes;
   var length = childNodes.length;
-  
+
   for (var i = 0; i < length; i++)
   {
     var childNode = childNodes[i];
@@ -523,7 +526,7 @@ TrPage.prototype._loadScript = function(source)
   var loadedLibraries = this._loadedLibraries;
   if (loadedLibraries[source])
     return;
-    
+
   loadedLibraries[source] = true;
   var xmlHttp = new TrXMLRequest();
   xmlHttp.setSynchronous(true);
@@ -580,11 +583,11 @@ TrPage._getTextContent = function(element)
     var textContent = element.innerText;
     if (textContent == undefined)
       textContent = element.text;
-        
+
     return textContent;
   }
 
-  // Safari doesn't have "innerText", "text" or "textContent" - 
+  // Safari doesn't have "innerText", "text" or "textContent" -
   // (at least not for XML nodes).  So sum up all the text children
   if (_agent.isSafari)
   {
@@ -677,12 +680,12 @@ TrPage.prototype.removeDomReplaceListener = function(listener, instance)
   // remove the listener/instance combination
   var domReplaceListeners = this._domReplaceListeners;
   var length = domReplaceListeners.length;
-  
+
   for (var i = 0; i < length; i++)
   {
     var currListener = domReplaceListeners[i];
     i++;
-    
+
     if (currListener == listener)
     {
       var currInstance = domReplaceListeners[i];
@@ -693,17 +696,17 @@ TrPage.prototype.removeDomReplaceListener = function(listener, instance)
       }
     }
   }
-  
+
   // remove array, if empty
   if (domReplaceListeners.length == 0)
   {
     this._domReplaceListeners = null;
   }
 }
- 
+
 /**
  * Adds the styleClassMap entries to the existing internal
- * styleClassMap. Styles can then be accessed via the 
+ * styleClassMap. Styles can then be accessed via the
  * getStyleClass function.
  * @param styleClassMap() {key: styleClass, ...}
  */
@@ -719,7 +722,7 @@ TrPage.prototype.addStyleClassMap = function(styleClassMap)
   for (var key in styleClassMap)
     this._styleClassMap[key] = styleClassMap[key];
 }
- 
+
 /**
  * Return the styleClass for the given key.
  * @param key(String) Unique key to retrieve the styleClass
@@ -739,7 +742,7 @@ TrPage.prototype.getStyleClass = function(key)
 
 /**
  * Causes a partial submit to occur on a given component.  The specified
- * component will always be validated first (if appropriate), then optionally 
+ * component will always be validated first (if appropriate), then optionally
  * the whole form, prior to submission.
  * @param formId(String) Id of the form to partial submit.
  * @param inputId(String) Id of the element causing the partial submit.  If this
@@ -757,8 +760,8 @@ TrPage._autoSubmit = function(formId, inputId, event, validateForm, params)
     if (event["type"] == "hidden")
       event = window.event;
   }
-  
-  // If onchange is used for validation, then first validate 
+
+  // If onchange is used for validation, then first validate
   // just the current input
 
   var isValid = true;
@@ -772,16 +775,16 @@ TrPage._autoSubmit = function(formId, inputId, event, validateForm, params)
       params = new Object();
     params.event = "autosub";
     params.source = inputId;
-  
+
     _submitPartialChange(formId, validateForm, params, event);
   }
 }
 
 /**
- * Causes a partial submit to occur on a given component using the jsf.ajax.request call. The 
+ * Causes a partial submit to occur on a given component using the jsf.ajax.request call. The
  * specified component will not be validated (yet).
  * @param formId(String) Id of the form to partial submit.
- * @param inputId(String) Id of the element causing the partial submit.  
+ * @param inputId(String) Id of the element causing the partial submit.
  * @param event(Event) The javascript event object.
  * @param params(Object} additional parameters to send
  */
@@ -794,6 +797,18 @@ TrPage._delegateToJSFAjax = function(formId, inputId, event, params)
     params = {};
 
   // TODO: add execute and render targets??
-  
   jsf.ajax.request(source, event, params);
 }
+
+TrPage.prototype._jsfAjaxCallback = function(data)
+{
+  if (data.status == "complete")
+  {
+    _pprStopBlocking(window);
+  }
+}
+
+TrPage.prototype._jsfAjaxErrorCallback = function(data)
+{
+
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.

[myfaces-trinidad] 06/10: Added DOM replace listener and state change listener support with JSF 2 ajax events

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch jsf2_ajax
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git

commit 707b01ec44d245c8eacb53548eebc20b87c24686
Author: Andrew Robinson <ar...@apache.org>
AuthorDate: Thu Feb 25 23:43:30 2010 +0000

    Added DOM replace listener and state change listener support with JSF 2 ajax events
---
 .../src/main/webapp/demos/ajaxPPRDemos.xhtml       | 340 +++++++++++----------
 .../main/javascript/META-INF/adf/jsLibs/Page.js    | 104 ++++++-
 2 files changed, 277 insertions(+), 167 deletions(-)

diff --git a/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml b/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
index 46696ce..df31e8f 100644
--- a/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
+++ b/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
@@ -18,180 +18,190 @@
     under the License.
 
 -->
-<ui:composition
-  xmlns:ui="http://java.sun.com/jsf/facelets"
-  xmlns:h="http://java.sun.com/jsf/html"
-  xmlns:f="http://java.sun.com/jsf/core"
-  xmlns:tr="http://myfaces.apache.org/trinidad"
-  xmlns:trd="http://myfaces.apache.org/trinidad/demo"
-  xmlns:trh="http://myfaces.apache.org/trinidad/html">
-  <h:outputScript name="jsf.js" library="javax.faces" target="body" id="os"/>
-  <tr:document title="Partial Page Rendering Demos">
-    <tr:form>
-
-     <tr:panelPage>
-      <f:facet name="navigationGlobal">
-       <tr:navigationPane hint="buttons">
-        <tr:commandNavigationItem text="Return to Feature Demos page"
-                                immediate="true"
-                                action="demos"/>
-       </tr:navigationPane>
-      </f:facet>
 
-      <tr:panelHeader text="Welcome to the Apache Trinidad Partial Page Rendering Demos for JSF 2.0 Ajax">
-        <tr:outputFormatted styleUsage="instruction" id="of0"
-                            value="These demos test Trinidad PPR with JSF 2.0 Ajax using both
-                            trinidad and JSF components."/>
-        <tr:panelGroupLayout layout="vertical">
-          <f:facet name="separator">
-            <tr:spacer width="30" height="10"/>
-          </f:facet>
-          <tr:panelHeader text="Command components using JSF 2.0 native Ajax support" id="phCmd">
-            <tr:outputFormatted styleUsage="instruction" id="of10"
-                                value="Tests commandButton components wired to use either Ajax JS API
-                                by itself or both JSF 2 Ajax and trinidad PPR. Clicking these buttons
-                                should cause a partial or a full page submit (without errors) and
-                                update the field on the right."/>
-            <tr:spacer height="10" id="sp10"/>
-            <tr:panelGroupLayout layout="horizontal" id="pgl10">
-              <tr:panelGroupLayout layout="vertical" id="pgl11">
+<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
+                xmlns:f="http://java.sun.com/jsf/core" xmlns:tr="http://myfaces.apache.org/trinidad"
+                xmlns:trd="http://myfaces.apache.org/trinidad/demo"
+                xmlns:trh="http://myfaces.apache.org/trinidad/html">
+  <tr:document title="Partial Page Rendering Demos"
+    onload="init();">
+    <f:facet name="metaContainer">
+      <tr:group>
+        <trh:script>
+function pprStateChangeFunction(state)
+{
+  var inputText = document.getElementById("it1");
+  if (inputText.value.length)
+  {
+    inputText.value += "\n";
+  }
+  var stateStr = (state == TrRequestQueue.STATE_READY) ? "ready" : "busy";
+  inputText.value += "State has changed to "+stateStr;
+  inputText.scrollTop = inputText.scrollHeight;
+}
+function pprDomReplacementFunction(oldDom, newDom)
+{
+  var inputText = document.getElementById("it1");
+  if (inputText.value.length)
+  {
+    inputText.value += "\n";
+  }
+  if (newDom === document.body)
+  {
+    inputText.value += "Document body was replaced";
+  }
+  else
+  {
+    inputText.value += "DOM element with ID " +
+      newDom.getAttribute("id") + " was replaced";
+  }
+  inputText.scrollTop = inputText.scrollHeight;
+}
+function init()
+{
+  TrPage.getInstance().getRequestQueue().addStateChangeListener(pprStateChangeFunction);
+  TrPage.getInstance().addDomReplaceListener(pprDomReplacementFunction);
+}
+        </trh:script>
+      </tr:group>
+    </f:facet>
+    <tr:form>
+      <tr:panelPage>
+        <f:facet name="navigationGlobal">
+          <tr:panelGroupLayout id="pgl1" layout="horizontal">
+            <f:facet name="separator">
+              <tr:spacer width="10" />
+            </f:facet>
+            <tr:navigationPane hint="buttons">
+              <tr:commandNavigationItem text="Return to Feature Demos page" immediate="true"
+                                        action="demos"/>
+            </tr:navigationPane>
+            <tr:statusIndicator id="si1" />
+          </tr:panelGroupLayout>
+        </f:facet>
+        <tr:panelHeader text="Welcome to the Apache Trinidad Partial Page Rendering Demos for JSF 2.0 Ajax">
+          <tr:outputFormatted styleUsage="instruction" id="of0"
+                              value="These demos test Trinidad PPR with JSF 2.0 Ajax using both trinidad and JSF components."/>
+          <tr:panelGroupLayout layout="vertical">
+            <f:facet name="separator">
+              <tr:spacer width="30" height="10"/>
+            </f:facet>
+            <tr:panelHeader text="Command components using JSF 2.0 native Ajax support" id="phCmd">
+              <tr:outputFormatted styleUsage="instruction" id="of10"
+                                  value="Tests commandButton components wired to use either Ajax JS API by itself or both JSF 2 Ajax and trinidad PPR. Clicking these buttons should cause a partial or a full page submit (without errors) and update the field on the right."/>
+              <tr:spacer height="10" id="sp10"/>
+              <tr:panelGroupLayout layout="horizontal" id="pgl10">
+                <tr:panelGroupLayout layout="vertical" id="pgl11">
+                  <f:facet name="separator">
+                    <tr:spacer height="6" id="sp11"/>
+                  </f:facet>
+                  <tr:outputFormatted styleUsage="instruction"
+                                      value="tr:commandButton using jsf.ajax.request and partialSubmit=true."
+                                      id="of11"/>
+                  <tr:commandButton id="axBtn1" partialSubmit="true" text="Partial Submit"
+                                    shortDesc="partialSubmit"
+                                    actionListener="#{partialDemoUtil.action}"/>
+                  <!--f:ajax event="action" render=""/-->
+                  <tr:outputFormatted styleUsage="instruction"
+                                      value="tr:commandButton using jsf.ajax.request." id="of12"/>
+                  <tr:commandButton id="axBtn2" text="Full Submit" shortDesc="fullSubmit"
+                                    actionListener="#{partialDemoUtil.action}"/>
+                  <tr:outputFormatted styleUsage="instruction"
+                                      value="h:commandButton using jsf.ajax.request." id="of13"/>
+                </tr:panelGroupLayout>
+                <tr:spacer width="30" height="10" id="sp12"/>
+                <tr:panelGroupLayout id="pgl12">
+                  <tr:panelLabelAndMessage label="Button Clicked: " id="plm10">
+                    <tr:outputFormatted id="btnTarget" partialTriggers="axBtn1 axBtn2"
+                                        styleUsage="instruction"
+                                        value="#{partialDemoUtil.status.linkUpdate}">
+                      <f:convertDateTime pattern="HH:mm:ss"/>
+                    </tr:outputFormatted>
+                  </tr:panelLabelAndMessage>
+                </tr:panelGroupLayout>
+              </tr:panelGroupLayout>
+            </tr:panelHeader>
+            <tr:panelHeader text="InputText Component using JSF 2.0 Ajax" id="phInput">
+              <tr:outputFormatted styleUsage="instruction"
+                                  value="Tests autoSubmitting text fields which is also wired to use JSF 2.0 Ajax."/>
+              <tr:panelGroupLayout layout="horizontal" id="pgl20">
                 <f:facet name="separator">
-                  <tr:spacer height="6" id="sp11"/>
+                  <tr:spacer height="10" id="sp20"/>
                 </f:facet>
-                <tr:outputFormatted styleUsage="instruction" value="tr:commandButton using
-                    jsf.ajax.request and partialSubmit=true." id="of11"/>
-                <tr:commandButton id="axBtn1"
-                                partialSubmit="true"
-                                text="Partial Submit"
-                                shortDesc="partialSubmit"
-                                actionListener="#{partialDemoUtil.action}"/>
-                  <!--f:ajax event="action" render=""/-->
-                <tr:outputFormatted styleUsage="instruction" value="tr:commandButton using jsf.ajax.request."
-                 id="of12"/>
-                <tr:commandButton id="axBtn2"
-                                  text="Full Submit"
-                                  shortDesc="fullSubmit"
-                                  actionListener="#{partialDemoUtil.action}"/>
-
-                <tr:outputFormatted styleUsage="instruction" value="h:commandButton using jsf.ajax.request."
-                 id="of13"/>
-
-
+                <tr:panelGroupLayout layout="vertical" id="pgl21">
+                  <f:facet name="separator">
+                    <tr:spacer height="6" id="sp21"/>
+                  </f:facet>
+                  <tr:outputFormatted styleUsage="instruction"
+                                      value="tr:inputText with autoSubmit=true."
+                                      id="of20"/>
+                  <tr:inputText id="itxt1" autoSubmit="true"
+                                value="#{partialDemoUtil.status.textValue}"
+                                label="Enter text and tab out: "
+                                valueChangeListener="#{partialDemoUtil.valueChanged}"/>
+                  <tr:outputFormatted styleUsage="instruction"
+                                      value="tr:inputText with autoSubmit=true inside a subform"
+                                      id="of21"/>
+                  <tr:subform id="sf20">
+                    <tr:inputText autoSubmit="true" id="itxt2"
+                                  label="Enter a different text and tab out: "
+                                  value="#{partialDemoUtil.status.textValue}"
+                                  valueChangeListener="#{partialDemoUtil.valueChanged}"/>
+                  </tr:subform>
+                </tr:panelGroupLayout>
+                <tr:panelLabelAndMessage label="Input entered: ">
+                  <tr:outputFormatted id="itTarget" partialTriggers="itxt1 ::sf20:itxt2"
+                                      styleUsage="instruction"
+                                      value="#{partialDemoUtil.status.textStateText}"/>
+                </tr:panelLabelAndMessage>
               </tr:panelGroupLayout>
-
-              <tr:spacer width="30" height="10" id="sp12"/>
-
-              <tr:panelGroupLayout id="pgl12">
-                <tr:panelLabelAndMessage label="Button Clicked: " id="plm10">
-                  <tr:outputFormatted id="btnTarget"
-                                     partialTriggers="axBtn1 axBtn2"
-                                     styleUsage="instruction"
-                                     value="#{partialDemoUtil.status.linkUpdate}">
+            </tr:panelHeader>
+            <tr:panelHeader text="Radio Buttons">
+              <tr:outputFormatted styleUsage="instruction"
+                                  value="This demo shows a two sets of radio buttons which use autoSubmit. There is also an output component which is listening on updates to the radio buttons and displaying status text accordingly."/>
+              <tr:panelGroupLayout layout="horizontal">
+                <tr:panelGroupLayout layout="vertical">
+                  <tr:panelGroupLayout layout="horizontal">
+                    <tr:outputFormatted styleUsage="instruction"
+                                        value="selectBooleanRadio buttons"/>
+                    <tr:panelGroupLayout layout="vertical">
+                      <tr:selectBooleanRadio id="sbr1" group="theGroup" selected="false"
+                                             text="item 1" autoSubmit="true"
+                                             valueChangeListener="#{partialDemoUtil.valueChanged}"/>
+                      <tr:selectBooleanRadio id="sbr2" group="theGroup" text="item 2"
+                                             selected="false" autoSubmit="true"
+                                             valueChangeListener="#{partialDemoUtil.valueChanged}"/>
+                      <tr:selectBooleanRadio id="sbr3" group="theGroup" text="item 3"
+                                             selected="false" autoSubmit="true"
+                                             valueChangeListener="#{partialDemoUtil.valueChanged}"/>
+                    </tr:panelGroupLayout>
+                  </tr:panelGroupLayout>
+                  <tr:spacer width="30" height="10"/>
+                  <tr:panelGroupLayout layout="vertical">
+                    <tr:selectOneRadio id="sor1" label="selectOneRadio buttons" autoSubmit="true"
+                                       valueChangeListener="#{partialDemoUtil.valueChanged}">
+                      <tr:selectItem label="item 1" value="1"/>
+                      <tr:selectItem label="item 2" value="2"/>
+                      <tr:selectItem label="item 3" value="3"/>
+                    </tr:selectOneRadio>
+                  </tr:panelGroupLayout>
+                </tr:panelGroupLayout>
+                <tr:spacer width="30" height="10"/>
+                <tr:panelLabelAndMessage label="Selected: ">
+                  <tr:outputFormatted id="rbTarget" partialTriggers="sbr1 sbr2 sbr3 sor1"
+                                      styleUsage="instruction"
+                                      value="#{partialDemoUtil.status.radioStateText}">
                     <f:convertDateTime pattern="HH:mm:ss"/>
                   </tr:outputFormatted>
                 </tr:panelLabelAndMessage>
-             </tr:panelGroupLayout>
-           </tr:panelGroupLayout>
-         </tr:panelHeader>
-
-         <tr:panelHeader text="InputText Component using JSF 2.0 Ajax" id="phInput">
-           <tr:outputFormatted styleUsage="instruction"
-                             value="Tests autoSubmitting text fields which is also wired to use JSF
-                             2.0 Ajax."/>
-            <tr:panelGroupLayout layout="horizontal" id="pgl20">
-              <f:facet name="separator">
-                <tr:spacer height="10" id="sp20"/>
-              </f:facet>
-              <tr:panelGroupLayout layout="vertical" id="pgl21">
-                <f:facet name="separator">
-                  <tr:spacer height="6" id="sp21"/>
-                </f:facet>
-                <tr:outputFormatted styleUsage="instruction" value="tr:inputText with
-                    autoSubmit=true." id="of20"/>
-                <tr:inputText id="itxt1"
-                              autoSubmit="true"
-                              value="#{partialDemoUtil.status.textValue}"
-                              label="Enter text and tab out: "
-                              valueChangeListener="#{partialDemoUtil.valueChanged}"/>
-                <tr:outputFormatted styleUsage="instruction" value="tr:inputText with
-                    autoSubmit=true inside a subform" id="of21"/>
-                <tr:subform id="sf20">
-                  <tr:inputText autoSubmit="true" id="itxt2" label="Enter a different text and tab out: "
-                                 value="#{partialDemoUtil.status.textValue}"
-                                 valueChangeListener="#{partialDemoUtil.valueChanged}"/>
-                </tr:subform>
               </tr:panelGroupLayout>
-
-              <tr:panelLabelAndMessage label="Input entered: ">
-               <tr:outputFormatted id="itTarget"
-                                   partialTriggers="itxt1 ::sf20:itxt2"
-                                   styleUsage="instruction"
-                                   value="#{partialDemoUtil.status.textStateText}"/>
-              </tr:panelLabelAndMessage>
-            </tr:panelGroupLayout>
-         </tr:panelHeader>
-
-         <tr:panelHeader text="Radio Buttons">
-           <tr:outputFormatted styleUsage="instruction"
-                               value="This demo shows a two sets of radio buttons which use autoSubmit.
-                               There is also an output component which is listening on updates to the
-                               radio buttons and displaying status text accordingly."/>
-          <tr:panelGroupLayout layout="horizontal">
-           <tr:panelGroupLayout layout="vertical">
-            <tr:panelGroupLayout layout="horizontal">
-             <tr:outputFormatted styleUsage="instruction"
-                                 value="selectBooleanRadio buttons"/>
-             <tr:panelGroupLayout layout="vertical">
-              <tr:selectBooleanRadio id="sbr1"
-                                     group="theGroup"
-                                     selected="false"
-                                     text="item 1"
-                                     autoSubmit="true"
-                                     valueChangeListener="#{partialDemoUtil.valueChanged}"/>
-              <tr:selectBooleanRadio id="sbr2"
-                                     group="theGroup"
-                                     text="item 2"
-                                     selected="false"
-                                     autoSubmit="true"
-                                     valueChangeListener="#{partialDemoUtil.valueChanged}"/>
-              <tr:selectBooleanRadio id="sbr3"
-                                     group="theGroup"
-                                     text="item 3"
-                                     selected="false"
-                                     autoSubmit="true"
-                                     valueChangeListener="#{partialDemoUtil.valueChanged}"/>
-             </tr:panelGroupLayout>
-            </tr:panelGroupLayout>
-            <tr:spacer width="30" height="10"/>
-            <tr:panelGroupLayout layout="vertical">
-             <tr:selectOneRadio id="sor1"
-                                label="selectOneRadio buttons"
-                                autoSubmit="true"
-                                valueChangeListener="#{partialDemoUtil.valueChanged}">
-              <tr:selectItem label="item 1" value="1" />
-              <tr:selectItem label="item 2" value="2" />
-              <tr:selectItem label="item 3" value="3" />
-             </tr:selectOneRadio>
-            </tr:panelGroupLayout>
-           </tr:panelGroupLayout>
-           <tr:spacer width="30" height="10"/>
-           <tr:panelLabelAndMessage label="Selected: ">
-            <tr:outputFormatted id="rbTarget"
-                                partialTriggers="sbr1 sbr2 sbr3 sor1"
-                                styleUsage="instruction"
-                                value="#{partialDemoUtil.status.radioStateText}">
-             <f:convertDateTime pattern="HH:mm:ss"/>
-            </tr:outputFormatted>
-           </tr:panelLabelAndMessage>
+            </tr:panelHeader>
           </tr:panelGroupLayout>
-         </tr:panelHeader>
-
-
-      </tr:panelGroupLayout>
-     </tr:panelHeader>
-     </tr:panelPage>
-
+          <tr:panelLabelAndMessage id="plam1" label="Ajax Status Log">
+            <tr:inputText id="it1" value="" simple="true" rows="7" columns="100" />
+          </tr:panelLabelAndMessage>
+        </tr:panelHeader>
+      </tr:panelPage>
     </tr:form>
-
   </tr:document>
 </ui:composition>
\ No newline at end of file
diff --git a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
index b9fb298..fcc8288 100644
--- a/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
+++ b/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
@@ -802,13 +802,113 @@ TrPage._delegateToJSFAjax = function(formId, inputId, event, params)
 
 TrPage.prototype._jsfAjaxCallback = function(data)
 {
-  if (data.status == "complete")
+  // TODO: move this code into the request queue to stop this gross infringement
+  // of encapsulation
+  switch (data.status)
   {
-    _pprStopBlocking(window);
+    case "begin":
+      this._requestQueue._state = TrRequestQueue.STATE_BUSY;
+      this._requestQueue._broadcastStateChangeEvent(this._requestQueue._state);
+      break;
+    case "success":
+      try
+      {
+        this._notifyDomReplacementListeners(this._ajaxOldDomElements);
+      }
+      finally
+      {
+        delete this._ajaxOldDomElements;
+      }
+      this._requestQueue._state = TrRequestQueue.STATE_READY;
+      this._requestQueue._broadcastStateChangeEvent(this._requestQueue._state);
+      break;
+    case "complete": default:
+      _pprStopBlocking(window);
+      // Collect the DOM elements that will be replaced to be able to fire the
+      // DOM replacement events
+      this._ajaxOldDomElements = this._getDomToBeUpdated(data.responseCode, data.responseXML);
+      break;
   }
 }
 
 TrPage.prototype._jsfAjaxErrorCallback = function(data)
 {
+  // TODO: move this code into the request queue to stop this gross infringement
+  // of encapsulation
+  this._requestQueue._state = TrRequestQueue.STATE_READY;
+  this._requestQueue._broadcastStateChangeEvent(this._requestQueue._state);
+  delete this._ajaxOldDomElements;
+}
+
+TrPage.prototype._notifyDomReplacementListeners = function(dataArray)
+{
+  var listeners = this._domReplaceListeners;
+  if (!listeners || listeners.length == 0)
+  {
+    return;
+  }
+  for (var i = 0, isize = dataArray.length; i < isize; ++i)
+  {
+    var oldElem = dataArray[i].element;
+    var id = dataArray[i].id;
+    var newElem = id == null ? document.body : document.getElementById(id);
+    for (var j = 0, jsize = listeners.length; j < jsize; ++j)
+    {
+      var currListener = listeners[j];
+      var currInstance = listeners[++j];
+      if (currInstance != null)
+      {
+        currListener.call(currInstance, oldElem, newElem);
+      }
+      else
+      {
+        currListener(oldElem, newElem);
+      }
+    }
+  }
+}
+
+TrPage.prototype._getDomToBeUpdated = function(status, responseXML)
+{
+  // check for a successful request
+  if (status < 200 || status >= 300)
+  {
+    return null;
+  }
+  // see if the response contains changes (not a redirect for example)
+  var nodes = responseXML.getElementsByTagName("partial-response");
+  var responseTypeNode = nodes.length ? nodes[0].firstChild : null;
+  if (!responseTypeNode || responseTypeNode.nodeName !== "changes")
+  {
+    return null;
+  }
+
+  var changeNodes = responseTypeNode.childNodes;
+  var oldElements = [];
+  for (var i = 0, size = changeNodes.length; i < size; ++i)
+  {
+    var node = changeNodes[i];
+    if (node.nodeName !== "update")
+    {
+      // We only care about updates as that is what Trinidad supported for the DOM
+      // replacement notification API
+      continue;
+    }
+
+    var id = node.getAttribute("id");
+    if (id == "javax.faces.ViewState")
+    {
+      continue;
+    }
+    if (id == "javax.faces.ViewRoot" || id == "javax.faces.ViewBody")
+    {
+      oldElements.push({ "id": null, "element": document.body });
+    }
+    else
+    {
+      oldElements.push({ "id": id, "element": document.getElementById(id) });
+    }
+  }
 
+  return oldElements;
 }
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.