ICEfaces
  1. ICEfaces
  2. ICE-7456

MyFaces 2: singleSubmit not working properly

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1-Beta2
    • Fix Version/s: 3.0.RC1, 3.0
    • Component/s: Bridge, Framework
    • Labels:
      None
    • Environment:
      MyFaces 2 ICEfaces 2
    • Assignee Priority:
      P1
    • Workaround Exists:
      Yes
    • Workaround Description:
      Replace singleSubmit with f:ajax tag

      Description

      There's an issue with some examples that use singleSubmit. For example, the Comp Suite Context Menu: Effects demo allows you to choose which effect to use when visually displaying the menu. The markup in question currently looks like this:

      <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.

        Activity

        Hide
        Ted Goddard added a comment -

        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">

        Show
        Ted Goddard added a comment - 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">
        Hide
        Ted Goddard added a comment -

        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;
        Show
        Ted Goddard added a comment - 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;
        Hide
        Ted Goddard added a comment -

        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.

        Show
        Ted Goddard added a comment - 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.
        Hide
        Ted Goddard added a comment -

        The spec simply says "identifier" rather than ID or name:

        http://download.oracle.com/docs/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/js-api/symbols/jsf.ajax.html#.request

        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.

        Show
        Ted Goddard added a comment - The spec simply says "identifier" rather than ID or name: http://download.oracle.com/docs/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/js-api/symbols/jsf.ajax.html#.request 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.
        Hide
        Deryk Sinotte added a comment -

        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))

        {                                options.execute = element.name + " " + options.execute;                            }

                               } else

        {                            options.execute = "@all";                        }

                               args["javax.faces.partial.execute"] = options.execute;
                           }
                       } else

        {                    options.execute = element.name + " " + element.id;                    args["javax.faces.partial.execute"] = options.execute;                }

        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.

        Show
        Deryk Sinotte added a comment - 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)) {                                options.execute = element.name + " " + options.execute;                            }                        } else {                            options.execute = "@all";                        }                        args ["javax.faces.partial.execute"] = options.execute;                    }                } else {                    options.execute = element.name + " " + element.id;                    args["javax.faces.partial.execute"] = options.execute;                } 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.

          People

          • Assignee:
            Ted Goddard
            Reporter:
            Deryk Sinotte
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: