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 2022/09/27 07:10:06 UTC

[myfaces] branch main updated: MYFACES-4390 follow up: Process multiple files via ajax (#322)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 932747d91 MYFACES-4390 follow up: Process multiple files via ajax (#322)
932747d91 is described below

commit 932747d912c5449c59702e29a1ce8638a16f2fee
Author: Volodymyr Siedlecki <vo...@gmail.com>
AuthorDate: Tue Sep 27 03:10:01 2022 -0400

    MYFACES-4390 follow up: Process multiple files via ajax (#322)
---
 .../META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js     | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
index 1375d420a..5681168db 100644
--- a/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
+++ b/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
@@ -81,6 +81,7 @@ _MF_SINGLTN(_PFX_XHR+"_AjaxUtils", _MF_OBJECT,
         var name = element.name;
         var tagName = element.tagName.toLowerCase();
         var elemType = element.type;
+        var isMultiple = element.multiple;
         if (elemType != null) {
             elemType = elemType.toLowerCase();
         }
@@ -126,7 +127,14 @@ _MF_SINGLTN(_PFX_XHR+"_AjaxUtils", _MF_OBJECT,
                     && ((elemType != "checkbox" && elemType != "radio") || element.checked)) {
                 if ('undefined' != typeof element.files && element.files != null && _RT.getXHRLvl() >= 2 && element.files.length) {
                     //xhr level2
-                    targetBuf.append(name, element.files[0]);
+                    for(var r = 0;r < element.files.length; r++){
+                        targetBuf.append(name, element.files[r]);
+                        // don't add any more files
+                        if(!isMultiple){ 
+                            break;
+                        }
+                    }
+                   
                 } else {
                     targetBuf.append(name, element.value);
                 }