ICEfaces
  1. ICEfaces
  2. ICE-8269

Application focus request does not work under specific conditions

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.0.1, EE-3.0.0.GA, 3.1.0.BETA2
    • Fix Version/s: None
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      JBoss 7.1.1, tested with Internet Explorer 8 and Firefox 10

      Description

      The JavascriptContext.focus and JavascriptContext.applicationFocus does not always successfully place the focus where it is requested. The following test case make it easilly reproducable under 3.1.0BETA2, EE-3.0.0.GA or 3.0.1 versions.

      XHTML :

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
                            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:ice="http://www.icesoft.com/icefaces/component">
      <h:head>
      <title>Test focus</title>
      </h:head>
      <h:body>
      <ice:form id="testfocusform">
      <h:messages />
      <ice:panelCollapsible expanded="true">
      <f:facet name="header">
      <ice:outputText value="FORM" />
      </f:facet>
      <ice:inputText action="#{testFocusBean.submit}" id="f1"
      value="#{testFocusBean.f1}" />
      <br />
      <ice:inputText action="#{testFocusBean.submit}" id="f2"
      value="#{testFocusBean.f2}" />
      <br />
      <ice:commandButton action="#{testFocusBean.submit}" value="submit" />
      </ice:panelCollapsible>
      <ice:panelCollapsible expanded="true"
      rendered="#{testFocusBean.f1 ne 10}">
      <f:facet name="header">
      <ice:outputText value="RESULTS" />
      </f:facet>
      <ice:outputText value="F1 : #{testFocusBean.f1}" />
      <br />
      <ice:outputText value="F2 : #{testFocusBean.f2}" />
      </ice:panelCollapsible>
      </ice:form>
      </h:body>
      </html>


      JAVA :

      public class TestFocusBean {
        private Integer f1;
        private Integer f2;

        public Integer getF1() {
          return f1;
        }

        public void setF1(Integer f1) {
          this.f1 = f1;
        }

        public Integer getF2() {
          return f2;
        }

        public void setF2(Integer f2) {
          this.f2 = f2;
        }

        public void submit() {
          FacesContext context = FacesContext.getCurrentInstance();
          if (f1 == 10) {
            FacesMessage fm = new FacesMessage();
            fm.setDetail("ERROR");
            fm.setSummary("ERROR");
            fm.setSeverity(FacesMessage.SEVERITY_ERROR);
            context.addMessage("testfocusform:f1", fm);
          }
          JavascriptContext.applicationFocus(context, "testfocusform:f1");
        }
      }

      How to reproduce it : first enter 20 it the first field and 30 in the second one and submit the form with the "enter" key in one of the fields. You'll see that the focus is correctly placed in the first field. Then, enter 10 in the first field and submit the form with the "enter" key in one of the two fields. You'll see that the focus is NOT placed in the first field of the form.

      The behavior is strictly this :
       - going from a state with the error message to a state without the error message produces the bug (no focus)
       - going from a state without the error message to a state with the error message produces the bug (no focus)
       - any other submit (error message to error message state or no error to no error message state) will place correctly the focus in the first field.

      Additional remarks :
       - this strange behavior appears only when submitting with the "enter" key in one of the form fields (pressing with the mouse on the button does not trigger it)
       - it seems somehow related to the fact that the form and results are placed in collapsible panels. The same code without the two collapsible panels do work properly

        Activity

        Hide
        Patrick Mingard added a comment -

        I related this issue to "Framework" more by elimination of the others. I don't really know if I made the right choice for this point.

        Show
        Patrick Mingard added a comment - I related this issue to "Framework" more by elimination of the others. I don't really know if I made the right choice for this point.

          People

          • Assignee:
            Unassigned
            Reporter:
            Patrick Mingard
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: