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

mleila pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 9dbaf721cd Fixed: Add missing control to allow callback propagation 
(OFBIZ-12664)
9dbaf721cd is described below

commit 9dbaf721cdb38031e396b39e17c8ae4b4247bb75
Author: MLeila <mle...@apache.org>
AuthorDate: Thu Feb 6 17:08:44 2025 +0100

    Fixed: Add missing control to allow callback propagation (OFBIZ-12664)
    
    Fix the propagation of the callback: currently the callback is applied
    even though we have a propagatecallback option.
    Manage the case "update-area on click"
---
 .../ofbiz/widget/renderer/macro/MacroFormRenderer.java | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
index 28c9b4e79f..638abe0dbc 100644
--- 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
+++ 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java
@@ -464,20 +464,28 @@ public final class MacroFormRenderer implements 
FormStringRenderer {
             }
         }
         String formId = FormRenderer.getCurrentContainerId(modelForm, context);
-        List<ModelForm.UpdateArea> updateAreas = 
modelForm.getOnSubmitUpdateAreas();
+        List<ModelForm.UpdateArea> updateAreas = new LinkedList<>();
+        List<ModelForm.UpdateArea> onSubmitUpdateAreas = 
modelForm.getOnSubmitUpdateAreas();
+        if (UtilValidate.isNotEmpty(onSubmitUpdateAreas)) {
+            updateAreas.addAll(onSubmitUpdateAreas);
+        }
+
+        // Retrieve on click event for submit field
+        List<ModelForm.UpdateArea> onClickUpdateAreas = 
modelFormField.getOnClickUpdateAreas();
+        if (UtilValidate.isNotEmpty(onClickUpdateAreas)) {
+            updateAreas.addAll(onClickUpdateAreas);
+        }
+
         // This is here for backwards compatibility. Use on-event-update-area
         // elements instead.
         String backgroundSubmitRefreshTarget = 
submitField.getBackgroundSubmitRefreshTarget(context);
         ModelForm.UpdateArea jwtCallback = 
ModelForm.UpdateArea.fromJwtToken(context);
         if (UtilValidate.isNotEmpty(backgroundSubmitRefreshTarget)) {
-            if (updateAreas == null) {
-                updateAreas = new LinkedList<>();
-            }
             updateAreas.add(new ModelForm.UpdateArea("submit", formId, 
backgroundSubmitRefreshTarget));
         }
 
         // In context a callback is present and no other update area to call 
after the submit, so trigger it.
-        if (UtilValidate.isEmpty(updateAreas) && jwtCallback != null) {
+        if (UtilValidate.isEmpty(updateAreas) && jwtCallback != null && 
!submitField.getPropagateCallback()) {
             updateAreas = UtilMisc.toList(jwtCallback);
         }
         boolean ajaxEnabled = UtilValidate.isNotEmpty(updateAreas) && 
this.javaScriptEnabled;

Reply via email to