mojarra
mojarra copied to clipboard
Ajax redirect fails silently when extension is used
Ajax redirects fail silently when the
<?xml version='1.0' encoding='UTF-8'?>
<partial-response id="j_id1">
<changes>
<extension parameterNamespace="j_id1"></extension>
</changes>
<redirect url="/ajax-redirect-fails-silently-when-extension-is-used-reproducer-1.0-SNAPSHOT/faces/page2.xhtml"></redirect>
</partial-response>
If the extension element is removed, redirects work correctly:
<?xml version='1.0' encoding='UTF-8'?>
<partial-response id="j_id1">
<redirect url="/ajax-redirect-fails-silently-when-extension-is-used-reproducer-1.0-SNAPSHOT/faces/page2.xhtml"></redirect>
</partial-response>
Steps to reproduce:
1. Clone the reproducer project:
git clone https://github.com/stiemannkj1/ajax-redirect-fails-silently-when-extension-is-used-reproducer &&
cd ajax-redirect-fails-silently-when-extension-is-used-reproducer
2. Build the project with maven:
mvn clean install
3. Deploy the project to tomcat:
cp target/ajax-redirect-fails-silently-when-extension-is-used-reproducer*.war $TOMCAT_HOME/webapps/
4. Navigate to index.xhtml (http://localhost:8080/ajax-redirect-fails-silently-when-extension-is-used-reproducer-1.0-SNAPSHOT/faces/index.xhtml).
5. Click on the page2 button.
If the bug still exists, an ajax POST will occur with a redirect, but the browser will stay on index.html instead of navigating to page2.xhtml.
Affected Versions
[2.1.29-06, 2.2.13]
Reported by stiemannkj1
stiemannkj1 said: I've sent a pull request to fix this issue to vsingleton here: https://github.com/vsingleton/mojarra/pull/9
The fix should be forward ported and back ported.
zhangxinyuan said: I can't find your pull request from https://github.com/vsingleton/mojarra/pull/9 now.
stiemannkj1 said: Sorry, the link was broken due to a repo name change: https://github.com/vsingleton/mojarra_read-only_mirror/pull/9
stiemannkj1 said: vsingleton,
var partialResponse = xml.getElementsByTagName("partial-response")[0];
var partialResponseId = partialResponse.getAttribute("id");
var responseType = partialResponse.firstChild;
for (var i = 0; i < partialResponse.childNodes.length; i++) {
if (partialResponse.childNodes[i].nodeName === "error") {
responseType = partialResponse.childNodes[i];
break;
}
+
+ if (partialResponse.childNodes[i].nodeName === "redirect") {
+ responseType = partialResponse.childNodes[i];
+ }
}
if (responseType.nodeName === "error") { // it's an error
However, this change may violate the spec. The "Receiving The Ajax Response" section of the JSF Specification (section 13.3.4) states that:
The elements in the response must be processed in the order they appear in the response.
But, lines 2817-2822 of jsf.js seem to process
Manfred Riem, Ed Burns, what do you think?
- Kyle
Was assigned to ZhangXinyuan
This issue was imported from java.net JIRA JAVASERVERFACES-4187
Hi @stiemannkj1 ,could you please create a new pull request for this issue.
@xinyuan-zhang, PR here: https://github.com/javaserverfaces/mojarra/pull/4258
Note that I'm still not sure if this violates the spec:
@vsingleton, @manfredriem, @edburns, The "Receiving The Ajax Response" section of the JSF Specification (section 13.3.4) states that:
The elements in the response must be processed in the order they appear in the response.
However, lines 2817-2822 of
jsf.jsseem to process<error>elements before any other elements. If this is not a violation of the Spec, then<redirect>elements should recieve similar treatment, and this fix is valid. What do you think?
Please see this important message regarding community contributions to Mojarra.
https://javaee.groups.io/g/jsf-spec/message/30
Also, please consider joining that group, as that group has taken the place of the old [email protected] mailing list.
Thanks,
Ed Burns
@edburns, @xinyuan-zhang, I've signed the OCA, so my code should be able to be merged. But I'd appreciate any insight either of you have into whether the change violates the JSF Spec or not.