Skip to content

Commit

Permalink
Fixed: Add missing control to allow callback propagation (OFBIZ-12664)
Browse files Browse the repository at this point in the history
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"
  • Loading branch information
MkLeila committed Feb 6, 2025
1 parent c283e57 commit 9dbaf72
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -464,20 +464,28 @@ public void renderSubmitField(Appendable writer, Map<String, Object> context, Su
}
}
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;
Expand Down

0 comments on commit 9dbaf72

Please sign in to comment.