ICEfaces
  1. ICEfaces
  2. ICE-2241

requestFocus failes for ice:selectOneMenu

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.7RC1, 1.7
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      Netbeans5.5 w VWP, Tomcat 5.5.20

      Description

      When using requestFocus on an instance of ice:selectOneMenu the following error appears in the Firebug console

      [window] Failed to set focus on [memberEditForm:selectOneGroup] TypeError: id.asExtendedElement().focus is not a function

      Equivalent to string reported in http://jira.icefaces.org/browse/ICE-171

        Activity

        Hide
        Mircea Toma added a comment -

        Tested with Address demo wich uses ice:selectOneMenu and requestFocus() features.

        Show
        Mircea Toma added a comment - Tested with Address demo wich uses ice:selectOneMenu and requestFocus() features.
        Hide
        Alexander Proskurowski added a comment -

        May be this will help you .

        Here is the selectOneGroup from firebug as it appears in Firefox.

        <table id="memberEditForm:selectOneGroup" class="iceSelOneRb label-font" style="border-style: solid; border-width: 1px; margin: 2px; left: 144px; top: 144px; position: absolute; background-color: white; padding-left: 2px; padding-right: 2px;">
        <tbody>
        <tr>
        <td>
        <input id="memberEditForm:selectOneGroup:_1" type="radio" value="905" onclick="setFocus('');iceSubmitPartial(form, this, event);" name="memberEditForm:selectOneGroup"/>
        <label class="iceSelOneRb label-font">Admin</label>
        </td>
        <td>
        <input id="memberEditForm:selectOneGroup:_2" type="radio" value="902" onclick="setFocus('');iceSubmitPartial(form, this, event);" name="memberEditForm:selectOneGroup"/>
        <label class="iceSelOneRb label-font">Staff</label>
        </td>
        <td>
        <input id="memberEditForm:selectOneGroup:_3" type="radio" value="901" onclick="setFocus('');iceSubmitPartial(form, this, event);" name="memberEditForm:selectOneGroup"/>
        <label class="iceSelOneRb label-font">Member</label>
        </td>
        </tr>
        </tbody>
        </table>

        The error happens in icefaces-d2d.js on line 2058 (again from firebug)

        2057:Ice.Focus.setFocus=function(id)

        { 2058:window.setTimeout("Ice.Focus.setFocusNow('"+id+"');",100); 2059:}

        ;

        if I break on line 2058 value of id = 'memberEditForm:selectOneGroup' and error occurs
        However if before continuing if change value of id to 'memberEditForm:selectOneGroup:_1' which is first radio button everything works fine and focus is set to the first radio button.

        The fact that one of the radio buttons is not selected is not important. I've tested with the first selected and I have the same results as above.

        Olek

        Show
        Alexander Proskurowski added a comment - May be this will help you . Here is the selectOneGroup from firebug as it appears in Firefox. <table id="memberEditForm:selectOneGroup" class="iceSelOneRb label-font" style="border-style: solid; border-width: 1px; margin: 2px; left: 144px; top: 144px; position: absolute; background-color: white; padding-left: 2px; padding-right: 2px;"> <tbody> <tr> <td> <input id="memberEditForm:selectOneGroup:_1" type="radio" value="905" onclick="setFocus('');iceSubmitPartial(form, this, event);" name="memberEditForm:selectOneGroup"/> <label class="iceSelOneRb label-font">Admin</label> </td> <td> <input id="memberEditForm:selectOneGroup:_2" type="radio" value="902" onclick="setFocus('');iceSubmitPartial(form, this, event);" name="memberEditForm:selectOneGroup"/> <label class="iceSelOneRb label-font">Staff</label> </td> <td> <input id="memberEditForm:selectOneGroup:_3" type="radio" value="901" onclick="setFocus('');iceSubmitPartial(form, this, event);" name="memberEditForm:selectOneGroup"/> <label class="iceSelOneRb label-font">Member</label> </td> </tr> </tbody> </table> The error happens in icefaces-d2d.js on line 2058 (again from firebug) 2057:Ice.Focus.setFocus=function(id) { 2058:window.setTimeout("Ice.Focus.setFocusNow('"+id+"');",100); 2059:} ; if I break on line 2058 value of id = 'memberEditForm:selectOneGroup' and error occurs However if before continuing if change value of id to 'memberEditForm:selectOneGroup:_1' which is first radio button everything works fine and focus is set to the first radio button. The fact that one of the radio buttons is not selected is not important. I've tested with the first selected and I have the same results as above. Olek
        Hide
        Alexander Proskurowski added a comment -

        Additional comment.

        If I change requestFocus() in
        com.icesoft.faces.component.ext.HtmlSelectOneRadio.java

        to
        public void requestFocus()

        { ((BridgeFacesContext) FacesContext.getCurrentInstance()) .setFocusId("null"); JavascriptContext.focus(FacesContext.getCurrentInstance(), this.getClientId( FacesContext.getCurrentInstance()) + ":_1"); }

        Note an extra ":_1" appended to id (probably not a proper bug fix, I just wanted a quick test)

        Recompile and replace appropriate class file in icefaces-webui.jar I do not get any errors and focus is set to the first radio button.

        Olek

        Show
        Alexander Proskurowski added a comment - Additional comment. If I change requestFocus() in com.icesoft.faces.component.ext.HtmlSelectOneRadio.java to public void requestFocus() { ((BridgeFacesContext) FacesContext.getCurrentInstance()) .setFocusId("null"); JavascriptContext.focus(FacesContext.getCurrentInstance(), this.getClientId( FacesContext.getCurrentInstance()) + ":_1"); } Note an extra ":_1" appended to id (probably not a proper bug fix, I just wanted a quick test) Recompile and replace appropriate class file in icefaces-webui.jar I do not get any errors and focus is set to the first radio button. Olek
        Hide
        Mircea Toma added a comment -

        Now I can see what is going on. I was testing with ice:selectOneMenu rendering a 'select' tag not a set of radio buttons.
        When requestFocus() is invoked the browser receives a command to move focus on the root element of the component (the one owning the clientId). The radio buttons are rendered with a table as the root element which cannot gain focus. The renderer for ice:selectOneMenu will have to be modified to either render an anchor as the root element or move focus on one of the radio buttons.

        Show
        Mircea Toma added a comment - Now I can see what is going on. I was testing with ice:selectOneMenu rendering a 'select' tag not a set of radio buttons. When requestFocus() is invoked the browser receives a command to move focus on the root element of the component (the one owning the clientId). The radio buttons are rendered with a table as the root element which cannot gain focus. The renderer for ice:selectOneMenu will have to be modified to either render an anchor as the root element or move focus on one of the radio buttons.
        Hide
        Alexander Proskurowski added a comment -

        Sorry, my fault. Subject of the bug should have been "requestFocus fails for ice:selectOneRadio."

        Olek

        Show
        Alexander Proskurowski added a comment - Sorry, my fault. Subject of the bug should have been "requestFocus fails for ice:selectOneRadio." Olek
        Hide
        Ken Fyten added a comment -

        Need to analyze if any other standard components have this issue and document them as Known Issues in the release notes for the time being.

        Show
        Ken Fyten added a comment - Need to analyze if any other standard components have this issue and document them as Known Issues in the release notes for the time being.
        Hide
        Ken Fyten added a comment -

        Need to modify the renderer to place the requestFocus on the first radio button.

        Show
        Ken Fyten added a comment - Need to modify the renderer to place the requestFocus on the first radio button.
        Hide
        Adnan Durrani added a comment -

        After considering all possible options I found out the Alexander's suggestion most appropreate to fix this bug. As the line 166 of the radioRenderer promises to prodduce the id of the first radio element using the following pattern:
        clientid + ":_id" + index (1)

        It also allows to use the predefined focus API.

        revision: 15979

        Show
        Adnan Durrani added a comment - After considering all possible options I found out the Alexander's suggestion most appropreate to fix this bug. As the line 166 of the radioRenderer promises to prodduce the id of the first radio element using the following pattern: clientid + ":_id" + index (1) It also allows to use the predefined focus API. revision: 15979

          People

          • Assignee:
            Unassigned
            Reporter:
            Alexander Proskurowski
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: