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:34 UTC

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

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>.