Skip to content

Commit 9dbaf72

Browse files
committed
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"
1 parent c283e57 commit 9dbaf72

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,20 +464,28 @@ public void renderSubmitField(Appendable writer, Map<String, Object> context, Su
464464
}
465465
}
466466
String formId = FormRenderer.getCurrentContainerId(modelForm, context);
467-
List<ModelForm.UpdateArea> updateAreas = modelForm.getOnSubmitUpdateAreas();
467+
List<ModelForm.UpdateArea> updateAreas = new LinkedList<>();
468+
List<ModelForm.UpdateArea> onSubmitUpdateAreas = modelForm.getOnSubmitUpdateAreas();
469+
if (UtilValidate.isNotEmpty(onSubmitUpdateAreas)) {
470+
updateAreas.addAll(onSubmitUpdateAreas);
471+
}
472+
473+
// Retrieve on click event for submit field
474+
List<ModelForm.UpdateArea> onClickUpdateAreas = modelFormField.getOnClickUpdateAreas();
475+
if (UtilValidate.isNotEmpty(onClickUpdateAreas)) {
476+
updateAreas.addAll(onClickUpdateAreas);
477+
}
478+
468479
// This is here for backwards compatibility. Use on-event-update-area
469480
// elements instead.
470481
String backgroundSubmitRefreshTarget = submitField.getBackgroundSubmitRefreshTarget(context);
471482
ModelForm.UpdateArea jwtCallback = ModelForm.UpdateArea.fromJwtToken(context);
472483
if (UtilValidate.isNotEmpty(backgroundSubmitRefreshTarget)) {
473-
if (updateAreas == null) {
474-
updateAreas = new LinkedList<>();
475-
}
476484
updateAreas.add(new ModelForm.UpdateArea("submit", formId, backgroundSubmitRefreshTarget));
477485
}
478486

479487
// In context a callback is present and no other update area to call after the submit, so trigger it.
480-
if (UtilValidate.isEmpty(updateAreas) && jwtCallback != null) {
488+
if (UtilValidate.isEmpty(updateAreas) && jwtCallback != null && !submitField.getPropagateCallback()) {
481489
updateAreas = UtilMisc.toList(jwtCallback);
482490
}
483491
boolean ajaxEnabled = UtilValidate.isNotEmpty(updateAreas) && this.javaScriptEnabled;

0 commit comments

Comments
 (0)