From 442f1af399b97fe825fe425d3570195b9f9f6935 Mon Sep 17 00:00:00 2001 From: "Jonathan S. Fisher" Date: Wed, 28 Oct 2026 13:16:44 -0600 Subject: [PATCH] Fix MYFACES-4771 - return the elements unchanged when rootNamingContainerId is empty --- .../client/typescript/faces/impl/AjaxImpl.ts | 6 +++ .../test/xhrCore/RequestParamsTest.spec.ts | 44 +++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/api/src/client/typescript/faces/impl/AjaxImpl.ts b/api/src/client/typescript/faces/impl/AjaxImpl.ts index 6713361d9..d53d00de2 100644 --- a/api/src/client/typescript/faces/impl/AjaxImpl.ts +++ b/api/src/client/typescript/faces/impl/AjaxImpl.ts @@ -707,6 +707,12 @@ export namespace Implementation { * @param componentIdToTransform the componentId which needs post-processing */ const remapNamingContainer = (componentIdToTransform: string) => { + // without a namespaced view root the ids are client ids which already were + // resolved on the server, remapping them against the form's naming container + // can point them to the wrong element + if (!rootNamingContainerId) { + return componentIdToTransform; + } // pattern : must be prepended by viewRoot if there is one, // otherwise we are in a not namespaced then only the id has to match const rootNamingContainerPrefix = (rootNamingContainerId.length) ? rootNamingContainerId+SEP : EMPTY_STR; diff --git a/api/src/client/typescript/faces/test/xhrCore/RequestParamsTest.spec.ts b/api/src/client/typescript/faces/test/xhrCore/RequestParamsTest.spec.ts index 4c0d63d19..2aadd2362 100644 --- a/api/src/client/typescript/faces/test/xhrCore/RequestParamsTest.spec.ts +++ b/api/src/client/typescript/faces/test/xhrCore/RequestParamsTest.spec.ts @@ -265,6 +265,50 @@ describe("test for proper request param patterns identical to the old implementa done(); }); + /** + * MYFACES-4771: render and execute ids are client ids already resolved by the server, + * a form inside a naming container must not remap them to an element with the same id + * inside that naming container + */ + it("must not remap resolved ids to the form's naming container", function (done) { + window.document.body.innerHTML = ` +
+
+
+ + +
+
+
+`; + + try { + let event = { + isTrusted: true, + type: 'click', + target: document.getElementById("comp:form:btn"), + currentTarget: document.getElementById("comp:form:btn") + }; + faces.ajax.request(document.getElementById("comp:form:btn"), event as any, { + execute: "@this", + render: "messages" + }); + } catch (err) { + console.error(err); + expect(false).to.eq(true); + } + const requestBody = this.requests[0].requestBody; + let resultsMap = {}; + for (let val of requestBody.split("&")) { + let keyVal = val.split("="); + resultsMap[keyVal[0]] = keyVal[1]; + } + + expect(resultsMap["jakarta.faces.partial.render"]).to.eq("messages"); + expect(resultsMap["jakarta.faces.partial.execute"]).to.eq(encodeURIComponent("comp:form:btn")); + done(); + }); + /** * This test is based on Tobago 6.0.0 (Jakarte EE 10). */