ICEfaces
  1. ICEfaces
  2. ICE-4383

Javascript object 'this' does not work with onFocus event and ice:inputText

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8.1
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      FF 3.0.8, IE7

      Description

       <ice:form>
                      <ice:inputText id="idWhereLocationTextBox" styleClass="inputTextBox width90"
                                     value="#{myBean.whereLocation}"
                                     onfocus="javascript:clearTxt(this.id);"
                                     onblur="javascript:getTxt(this.id);"/>
                  </ice:form

      and

       <script>
                      function clearTxt(varI){
                          alert('onFocus:' + varI);
                      }

                      function getTxt(varI) {
                            alert('onBlur:' + varI);
                      }
        </script>

      In Firefox 3.0.8, the alert will return "onFocus:undefined" and in IE7 "onFocus j_id11" which is the ID of the form tag.

        Activity

        Hide
        Tyler Johnson added a comment -

        Sample app intended for deployment on Tomcat 6.

        http://localhost:8084/SC8209/main.jspx

        Show
        Tyler Johnson added a comment - Sample app intended for deployment on Tomcat 6. http://localhost:8084/SC8209/main.jspx
        Hide
        Mark Collette added a comment -

        Are you wanting the event target?

        Show
        Mark Collette added a comment - Are you wanting the event target?
        Hide
        Tyler Johnson added a comment -

        Yes, so in this case 'this' would refer to the calling inputText component.

        Ty

        Show
        Tyler Johnson added a comment - Yes, so in this case 'this' would refer to the calling inputText component. Ty
        Hide
        Arturo Zambrano added a comment - - edited

        In a plain HTML test, using 'this' in the onfocus attribute refers to the <input> (or <a>, or any focusable) element that just received focus. Under ICEfaces, 'this' refers to the window object in FF and to the containing <form> element in IE. This applies to both: elements rendered as part of ICEfaces components and to stand-alone elements hard-coded in the page. I guess the intention of the test app is to get a reference to the <input> element.

        Show
        Arturo Zambrano added a comment - - edited In a plain HTML test, using 'this' in the onfocus attribute refers to the <input> (or <a>, or any focusable) element that just received focus. Under ICEfaces, 'this' refers to the window object in FF and to the containing <form> element in IE. This applies to both: elements rendered as part of ICEfaces components and to stand-alone elements hard-coded in the page. I guess the intention of the test app is to get a reference to the <input> element.
        Hide
        Tyler Johnson added a comment -

        You are correct Arturo.

        Ty

        Show
        Tyler Johnson added a comment - You are correct Arturo. Ty
        Hide
        Arturo Zambrano added a comment -

        This issue seems to be started from a commit related to the issue ICE-4102 "Capture focus for any element that can receive it" (rev. 18359).

        Show
        Arturo Zambrano added a comment - This issue seems to be started from a commit related to the issue ICE-4102 "Capture focus for any element that can receive it" (rev. 18359).
        Hide
        Mircea Toma added a comment -

        Execute previously registered listeners so that 'this' variable points to the right element instance.

        Show
        Mircea Toma added a comment - Execute previously registered listeners so that 'this' variable points to the right element instance.

          People

          • Assignee:
            Mircea Toma
            Reporter:
            Tyler Johnson
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: