Details
Description
<ui:define name="example">
<h:form>
<icecore:singleSubmit/>
<h:panelGrid columns="3">
...
This doesn't work properly when running under MyFaces. Clicking a radio button does trigger a submit, but the resulting update simply resets the radio back to the default selection. Changing it to use an f:ajax tag appears to clear things up:
<ui:define name="example">
<h:form>
<f:ajax execute="@this" render="@all">
<h:panelGrid columns="3">
...
This isn't related to ACE at all. I can pare down the example to a very simply one using only stock components and the behaviour is the same.
-
Hide
- ice-7456.zip
- 32 kB
- Deryk Sinotte
-
- ice-7456/build.xml 1 kB
- __MACOSX/ice-7456/._build.xml 0.2 kB
- ice-7456/src/main/.../simple/SimpleBean.java 1.0 kB
- ice-7456/src/.../messages.properties 83 kB
- ice-7456/src/.../messages_en.properties 0.8 kB
- ice-7456/src/main/webapp/.DS_Store 6 kB
- __MACOSX/ice-7456/src/.../webapp/._.DS_Store 0.1 kB
- ice-7456/src/main/webapp/fajax.xhtml 2 kB
- __MACOSX/ice-7456/.../webapp/._fajax.xhtml 0.2 kB
- ice-7456/src/main/webapp/index.jsp 0.9 kB
- __MACOSX/ice-7456/src/.../webapp/._index.jsp 0.2 kB
- ice-7456/src/main/.../resources/.DS_Store 6 kB
- __MACOSX/ice-7456/.../resources/._.DS_Store 0.1 kB
- ice-7456/src/main/webapp/ss.xhtml 2 kB
- __MACOSX/ice-7456/src/.../webapp/._ss.xhtml 0.2 kB
- ice-7456/src/.../WEB-INF/faces-config.xml 1 kB
- __MACOSX/ice-7456/.../._faces-config.xml 0.2 kB
- ice-7456/src/main/webapp/WEB-INF/web.xml 3 kB
- __MACOSX/ice-7456/src/.../WEB-INF/._web.xml 0.2 kB
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
Attaching test case.
No matter what radio button is clicked on, the response is always:
<input checked="checked" id="j_id76603324_490dfe1:theColours:0" name="j_id76603324_490dfe1:theColours" type="radio" value="red" />
This value is submitted, which seems unusual:
javax.faces.partial.event=undefined
With f:ajax we have:
javax.faces.partial.event=change
however, fixing this does not seem sufficient
The following change in submit.js
+event.type = type(decoratedEvent);
just before
namespace.submitFunction(clonedElement, event, options);
resolves the javax.faces.partial.event difference, but does not affect the returned page update.
The contents of the two requests become:
(for singleSubmit)
4z8pu82_SUBMIT=1
javax.faces.ViewState=A%2FRyKRXY8NCEcSf%2BHaIwR2w4Qq%2BcnSwkueW5%2Br18lAEUYoDSkNFdygWEzCk3jB6cw3JxaPu5Yoal%0D%0A824hBPWsbZsxClcW0C9L35giy10JIrk6WDy%2Ba2a2aI8Cqnc%3D%0D%0A
j_id76603324_490dfe1%3AtheColours=blue
ice.window=1fgut0j52g
ice.view=v4z8pu82
ice.focus=
ice.event.target=j_id76603324_490dfe1%3AtheColours%3A1
ice.event.captured=j_id76603324_490dfe1%3AtheColours%3A1
ice.event.type=onchange
ice.submit.type=ice.se
ice.submit.serialization=element
javax.faces.partial.event=change
javax.faces.source=j_id76603324_490dfe1%3AtheColours%3A1
javax.faces.partial.ajax=true
javax.faces.partial.execute=%40this%20j_id76603324_490dfe1%3AtheColours%3A1
javax.faces.partial.render=%40all
v4z8pu82=v4z8pu82
(and f:ajax)
ice.window=1fgut0j52g
ice.view=v4z8pu82
j_id76603324_490dea6%3AtheColours2=blue
j_id76603324_490dea6_SUBMIT=1
javax.faces.ViewState=A%2FRyKRXY8NCEcSf%2BHaIwR2w4Qq%2BcnSwkueW5%2Br18lAEUYoDSkNFdygWEzCk3jB6cw3JxaPu5YoZd%0A9vPsdPr7EZsxClcW0C9LUYC%2F5f%2B3JG00%2FH7cBN7EA%2FgkgMg%3D%0A
javax.faces.behavior.event=valueChange
javax.faces.partial.event=change
javax.faces.source=j_id76603324_490dea6%3AtheColours2
javax.faces.partial.ajax=true
javax.faces.partial.execute=%40this%20j_id76603324_490dea6%3AtheColours2
javax.faces.partial.render=%40all
j_id76603324_490dea6=j_id76603324_490dea6
There appears to be some confusion with the event source being the ID of the element vs the name. Perhaps these are identical in mojarra but are not in myfaces.
Mojarra parameters:
v6niaio1=v6niaio1
javax.faces.ViewState=7608153838258384590%3A-5455391648256555334
j_idt6%3AtheColours=blue
javax.faces.source=j_idt6%3AtheColours%3A1
javax.faces.partial.event=change
javax.faces.partial.execute=j_idt6%3AtheColours%20j_idt6%3AtheColours%3A1
javax.faces.partial.render=%40all
ice.window=m3gutyqizu
ice.view=v6niaio1
ice.focus=
ice.event.target=j_idt6%3AtheColours%3A1
ice.event.captured=j_idt6%3AtheColours%3A1
ice.event.type=onchange
ice.submit.type=ice.se
ice.submit.serialization=element
javax.faces.partial.ajax=true
j_idt14=j_idt14
ice.window=m3gutyqizu
ice.view=v6niaio1
j_idt14%3AtheColours2=blue
javax.faces.ViewState=7608153838258384590%3A-5455391648256555334
javax.faces.source=j_idt14%3AtheColours2%3A1
javax.faces.partial.event=click
javax.faces.partial.execute=j_idt14%3AtheColours2%20j_idt14%3AtheColours2%3A1
javax.faces.partial.render=%40all
javax.faces.behavior.event=valueChange
javax.faces.partial.ajax=true
In the case of mojarra, the javax.faces.source and javax.faces.partial.execute have the same structure.
Mojarra markup:
<input id="j_idt6:theColours:0" name="j_idt6:theColours" type="radio" value="red">
<input id="j_idt14:theColours2:0" name="j_idt14:theColours2" onclick="mojarra.ab(this,event,'valueChange','@this','@all')" type="radio" value="red">
MyFaces markup:
<input checked="checked" id="j_id76603324_490dfe1:theColours:0" name="j_id76603324_490dfe1:theColours" type="radio" value="red">
<input checked="checked" id="j_id76603324_490dea6:theColours2:0" name="j_id76603324_490dea6:theColours2" onchange="jsf.ajax.request('j_id76603324_490dea6:theColours2',event,
{execute:'@this',render:'@all','javax.faces.behavior.event':'valueChange'})" type="radio" value="red">
This seems to be a fix in META-INF/internal-resources/javax.faces/jsf-uncompressed-full.js:
/**
- binding contract the javax.faces.source must be set
*/
//passThrgh[this.P_PARTIAL_SOURCE] = elementId;
passThrgh[this.P_PARTIAL_SOURCE] = elem.name;
Please take a look at the above myfaces change – we need to decide if they should modify this or if this is still really a problem in our code.
The spec simply says "identifier" rather than ID or name:
so the test is likely whether the above change fixes the problem. Alternatively, the MyFaces RadioButtonRenderer could be modified to accept a decode from a javax.faces.source that matches any ID it has written.
So it appears that, when using singleSubmit with MyFaces, the "javax.faces.execute" parameter does not include the name of the component. For example, if you run the test case and run the ss.xhtml page:
javax.faces.partial.execute:@this j_id76603324_490dfe1:theColours:0
Running the fajax.xhtml page:
javax.faces.partial.execute:j_id779036716_2e6f2877:theColours
MyFaces looks like it processes things differently with the f:ajax tag whereas with singleSubmit, from the client perspective, it doesn't look like an Ajax request.
Including the element.name is important for things like radio buttons and checkboxes because the id of the radio button/checkbox is indexed:
j_id76603324_490dfe1:theColours:0
but the actual component doesn't include this
j_id76603324_490dfe1:theColours
Without the element.name in this case, MyFaces fails to run the partial execution against the component and it doesn't get decode() 'd.
Mojarra appears to append the element.name to the outgoing request regardless.
if (options.execute) {
none = options.execute.search(/@none/);
if (none < 0) {
all = options.execute.search(/@all/);
if (all < 0) {
options.execute = options.execute.replace("@this", element.id);
options.execute = options.execute.replace("@form", form.id);
var temp = options.execute.split(' ');
if (!isInArray(temp, element.name))
} else
{ options.execute = "@all"; } args["javax.faces.partial.execute"] = options.execute;
}
} else
So I've checked in a change to submit.js that appends the element.name to the execute parameter for radio buttons and checkboxes (if it's not already there) which fixes the issue we are seeing. The fix is currently only applied to singleSubmit for radio buttons and checkboxes as that's the only place we are currently seeing this behaviour.
Assigned to Ted.
Attached test case contains 2 identical pages except that one uses singleSubmit (ss.xhtml) and one uses f:ajax (fajax.xhtml). You can build it by unzipping it to the icefaces2/samples/core directory and using the normal build mechanisms:
Mojarra:
ant clean servlet-profile
MyFaces:
ant -Dmyfaces="true" clean servlet-profile