You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2018/11/07 09:46:06 UTC

[myfaces] branch 2.2.x updated: MYFACES-3751 Log exception on submitForm in Javascript

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

tandraschko pushed a commit to branch 2.2.x
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/2.2.x by this push:
     new 4f724c9  MYFACES-3751 Log exception on submitForm in Javascript
4f724c9 is described below

commit 4f724c9f14c230fcb824f5ab6bc7ab4abdbd02e2
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Wed Nov 7 10:46:02 2018 +0100

    MYFACES-3751 Log exception on submitForm in Javascript
---
 .../resources/myfaces/_impl/_util/_OamSubmit.js    | 42 ++++++++++++----------
 .../META-INF/resources/myfaces/_impl/oamSubmit.js  | 42 ++++++++++++----------
 2 files changed, 48 insertions(+), 36 deletions(-)

diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_OamSubmit.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_OamSubmit.js
index 544e6b3..e85ce53 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_OamSubmit.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_OamSubmit.js
@@ -36,7 +36,7 @@ if (!myfaces.oam) {
             if (typeof form == 'undefined') {
                 form = document.getElementById(formname);
             }
-    
+
             if (typeof form.elements[name] != 'undefined' && (form.elements[name].nodeName == 'INPUT' || form.elements[name].nodeName == 'input')) {
                 form.elements[name].value = value;
             }
@@ -49,7 +49,7 @@ if (!myfaces.oam) {
                 form.appendChild(newInput);
             }
         };
-        
+
         /**
          * clears a hidden input field
          *
@@ -59,17 +59,17 @@ if (!myfaces.oam) {
          */
         this.clearHiddenInput = function(formname, name, value) {
             var form = document.forms[formname];
-    
+
             if (typeof form == 'undefined') {
                 form = document.getElementById(formname);
             }
-    
+
             var hInput = form.elements[name];
             if (typeof hInput != 'undefined') {
                 form.removeChild(hInput);
             }
         };
-        
+
         /**
          * does special form submit remapping
          * remaps the issuing command link into something
@@ -81,22 +81,22 @@ if (!myfaces.oam) {
          * @param params
          */
         this.submitForm = function(formName, linkId, target, params) {
-    
+
             var clearFn = 'clearFormHiddenParams_' + formName.replace(/-/g, '\$:').replace(/:/g, '_');
             if (typeof window[clearFn] == 'function') {
                 window[clearFn](formName);
             }
-    
+
             var form = document.forms[formName];
             if (typeof form == 'undefined') {
                 form = document.getElementById(formName);
             }
-    
+
             //autoscroll code
             if (myfaces.core.config.autoScroll && typeof window.getScrolling != 'undefined') {
                 myfaces.oam.setHiddenInput(formName, 'autoScroll', getScrolling());
             }
-    
+
             if (myfaces.core.config.ieAutoSave) {
                 var agentString = navigator.userAgent.toLowerCase();
                 var version = navigator.appVersion;
@@ -106,7 +106,7 @@ if (!myfaces.oam) {
                     }
                 }
             }
-    
+
             var oldTarget = form.target;
             if (target != null) {
                 form.target = target;
@@ -115,11 +115,11 @@ if (!myfaces.oam) {
                 for (var i = 0, param; (param = params[i]); i++) {
                     myfaces.oam.setHiddenInput(formName, param[0], param[1]);
                 }
-    
+
             }
-    
+
             myfaces.oam.setHiddenInput(formName, formName + ':' + '_idcl', linkId);
-    
+
             if (form.onsubmit) {
                 var result = form.onsubmit();
                 if ((typeof result == 'undefined') || result) {
@@ -127,27 +127,33 @@ if (!myfaces.oam) {
                         form.submit();
                     }
                     catch(e) {
+                        if (window.console) {
+                            console.error(e);
+                        }
                     }
                 }
-    
+
             }
             else {
                 try {
                     form.submit();
                 }
                 catch(e) {
+                    if (window.console) {
+                        console.error(e);
+                    }
                 }
             }
-    
+
             form.target = oldTarget;
             if ((typeof params != 'undefined') && params != null) {
-    
+
                 for (var i = 0, param; (param = params[i]); i++) {
                     myfaces.oam.clearHiddenInput(formName, param[0], param[1]);
                 }
-    
+
             }
-    
+
             myfaces.oam.clearHiddenInput(formName, formName + ':' + '_idcl', linkId);
             return false;
         };
diff --git a/shared/src/main/javascript/META-INF/resources/myfaces/_impl/oamSubmit.js b/shared/src/main/javascript/META-INF/resources/myfaces/_impl/oamSubmit.js
index 544e6b3..e85ce53 100644
--- a/shared/src/main/javascript/META-INF/resources/myfaces/_impl/oamSubmit.js
+++ b/shared/src/main/javascript/META-INF/resources/myfaces/_impl/oamSubmit.js
@@ -36,7 +36,7 @@ if (!myfaces.oam) {
             if (typeof form == 'undefined') {
                 form = document.getElementById(formname);
             }
-    
+
             if (typeof form.elements[name] != 'undefined' && (form.elements[name].nodeName == 'INPUT' || form.elements[name].nodeName == 'input')) {
                 form.elements[name].value = value;
             }
@@ -49,7 +49,7 @@ if (!myfaces.oam) {
                 form.appendChild(newInput);
             }
         };
-        
+
         /**
          * clears a hidden input field
          *
@@ -59,17 +59,17 @@ if (!myfaces.oam) {
          */
         this.clearHiddenInput = function(formname, name, value) {
             var form = document.forms[formname];
-    
+
             if (typeof form == 'undefined') {
                 form = document.getElementById(formname);
             }
-    
+
             var hInput = form.elements[name];
             if (typeof hInput != 'undefined') {
                 form.removeChild(hInput);
             }
         };
-        
+
         /**
          * does special form submit remapping
          * remaps the issuing command link into something
@@ -81,22 +81,22 @@ if (!myfaces.oam) {
          * @param params
          */
         this.submitForm = function(formName, linkId, target, params) {
-    
+
             var clearFn = 'clearFormHiddenParams_' + formName.replace(/-/g, '\$:').replace(/:/g, '_');
             if (typeof window[clearFn] == 'function') {
                 window[clearFn](formName);
             }
-    
+
             var form = document.forms[formName];
             if (typeof form == 'undefined') {
                 form = document.getElementById(formName);
             }
-    
+
             //autoscroll code
             if (myfaces.core.config.autoScroll && typeof window.getScrolling != 'undefined') {
                 myfaces.oam.setHiddenInput(formName, 'autoScroll', getScrolling());
             }
-    
+
             if (myfaces.core.config.ieAutoSave) {
                 var agentString = navigator.userAgent.toLowerCase();
                 var version = navigator.appVersion;
@@ -106,7 +106,7 @@ if (!myfaces.oam) {
                     }
                 }
             }
-    
+
             var oldTarget = form.target;
             if (target != null) {
                 form.target = target;
@@ -115,11 +115,11 @@ if (!myfaces.oam) {
                 for (var i = 0, param; (param = params[i]); i++) {
                     myfaces.oam.setHiddenInput(formName, param[0], param[1]);
                 }
-    
+
             }
-    
+
             myfaces.oam.setHiddenInput(formName, formName + ':' + '_idcl', linkId);
-    
+
             if (form.onsubmit) {
                 var result = form.onsubmit();
                 if ((typeof result == 'undefined') || result) {
@@ -127,27 +127,33 @@ if (!myfaces.oam) {
                         form.submit();
                     }
                     catch(e) {
+                        if (window.console) {
+                            console.error(e);
+                        }
                     }
                 }
-    
+
             }
             else {
                 try {
                     form.submit();
                 }
                 catch(e) {
+                    if (window.console) {
+                        console.error(e);
+                    }
                 }
             }
-    
+
             form.target = oldTarget;
             if ((typeof params != 'undefined') && params != null) {
-    
+
                 for (var i = 0, param; (param = params[i]); i++) {
                     myfaces.oam.clearHiddenInput(formName, param[0], param[1]);
                 }
-    
+
             }
-    
+
             myfaces.oam.clearHiddenInput(formName, formName + ':' + '_idcl', linkId);
             return false;
         };