Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/src/client/typescript/faces/impl/AjaxImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 :<anything> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
<div id="messages"></div>
<div id="comp">
<form id="comp:form" action="/test.xhtml" method="post">
<input type="hidden" name="jakarta.faces.ViewState" id="j_id__v_0:jakarta.faces.ViewState:1" value="viewStateValue">
<button type="button" id="comp:form:btn" name="comp:form:btn">go</button>
<div id="comp:messages"></div>
</form>
</div>
`;

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).
*/
Expand Down
Loading