MyFaces Trinidad
  1. MyFaces Trinidad
  2. TRINIDAD-713

Using "name" as the id for a component breaks form submission. "name" appears to be an undocumented reserved identifier.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.2-core
    • Fix Version/s: 1.0.4-core
    • Component/s: Components
    • Labels:
      None

      Description

      Using the trinidad-blank as an example, if the the id of the input field in "page1.jspx" is changed from:

      <tr:inputText label="Your name" id="input1" value="#

      {helloWorldBacking.name}" required="true"/>

      to:

      <tr:inputText label="Your name" id="name" value="#{helloWorldBacking.name}

      " required="true"/>

      nothing happens when the "press me" button is pushed (the form is not posted).

      The following JavaScript error is reported:

      Error ``TypeError: a0.split is not a function'' [xs] in file ``http://localhost:8080/trinidad/adf/jsLibs/Common1_2_2.js'', line 4512, character 0.

      In the code fragment below "a0" has been resolved to the HTMLFormElement, but apparently because the form contains a button element named "name", "a0.name" does not return the form name, but instead the button instance, and "split" is not a method on HTMLButtonElement.

      4861 if(!a0)
      4862 return false;
      4863 var a6=window["_"+_getJavascriptId(a0.name)+"Validator"];
      4864 if(a6==(void 0))

      function _getJavascriptId(a0)
      4511

      { 4512 return a0.split(':').join('_'); 4513 }

      Is there a way in JavaScript to avoid this name conflict? It does not seem reasonable it is illegal to add an element called "name" to a form.

        Activity

        Mike Hanafey created issue -
        Hide
        Mike Hanafey added a comment -

        A bit more information about the failure was added to the description.

        Show
        Mike Hanafey added a comment - A bit more information about the failure was added to the description.
        Mike Hanafey made changes -
        Field Original Value New Value
        Description  Using the trinidad-blank as an example, if the the id of the input field in "page1.jspx" is changed from:

                 <tr:inputText label="Your name" id="input1" value="#{helloWorldBacking.name}" required="true"/>

        to:

                 <tr:inputText label="Your name" id="name" value="#{helloWorldBacking.name}" required="true"/>

        nothing happens when the "press me" button is pushed (the form is not posted).
         Using the trinidad-blank as an example, if the the id of the input field in "page1.jspx" is changed from:

                 <tr:inputText label="Your name" id="input1" value="#{helloWorldBacking.name}" required="true"/>

        to:

                 <tr:inputText label="Your name" id="name" value="#{helloWorldBacking.name}" required="true"/>

        nothing happens when the "press me" button is pushed (the form is not posted).

        The following JavaScript error is reported:

        Error ``TypeError: a0.split is not a function'' [xs] in file ``http://localhost:8080/trinidad/adf/jsLibs/Common1_2_2.js&#39;&#39;, line 4512, character 0.

        In the code fragment below "a0" has been resolved to the HTMLFormElement, but apparently because the form contains a button element named "name", "a0.name" does not return the form name, but instead the button instance, and "split" is not a method on HTMLButtonElement.

            4861 if(!a0)
            4862 return false;
            4863 var a6=window["_"+_getJavascriptId(a0.name)+"Validator"];
            4864 if(a6==(void 0))

                      function _getJavascriptId(a0)
           4511 {
           4512 return a0.split(':').join('_');
           4513 }

        Is there a way in JavaScript to avoid this name conflict? It does not seem reasonable it is illegal to add an element called "name" to a form.
        Hide
        Mike Hanafey added a comment -

        Could someone comment on this issue? Is "name" and invalid value for the id attribute, or is this a bug?

        Show
        Mike Hanafey added a comment - Could someone comment on this issue? Is "name" and invalid value for the id attribute, or is this a bug?
        Hide
        Leonardo Uribe added a comment -

        Ok, the problem is because when a component inside a form has an id with "name" in his value override the property form.name on the DOM tree. The solution is check when this occurs creating a function like this
        (this function takes the proper attribute name when this occurs):

        function _getFormName(form){
        var name = form.name;

        if (typeof name == 'object')
        {
        if (_agent.isIE)

        { return form.attributes['name'].nodeValue; }

        else

        { return form.getAttribute('name'); }

        }
        else

        { return name; }

        }

        and replacing all calls like form.name with _getFormName(form)

        Show
        Leonardo Uribe added a comment - Ok, the problem is because when a component inside a form has an id with "name" in his value override the property form.name on the DOM tree. The solution is check when this occurs creating a function like this (this function takes the proper attribute name when this occurs): function _getFormName(form){ var name = form.name; if (typeof name == 'object') { if (_agent.isIE) { return form.attributes['name'].nodeValue; } else { return form.getAttribute('name'); } } else { return name; } } and replacing all calls like form.name with _getFormName(form)
        Leonardo Uribe made changes -
        Attachment patchInvalidIdNameComponent.patch [ 12367111 ]
        Leonardo Uribe made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Adam Winer made changes -
        Resolution Fixed [ 1 ]
        Fix Version/s 1.0.4-core [ 12312810 ]
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Assignee Adam Winer [ adamwiner ]
        Matthias Weßendorf made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Patch Available Patch Available
        17d 3h 15m 1 Leonardo Uribe 04/Oct/07 22:40
        Patch Available Patch Available Resolved Resolved
        8d 23h 1m 1 Adam Winer 13/Oct/07 21:42
        Resolved Resolved Closed Closed
        29d 23h 1m 1 Matthias Weßendorf 12/Nov/07 19:43

          People

          • Assignee:
            Adam Winer
            Reporter:
            Mike Hanafey
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development