Uploaded image for project: 'MyFaces Tomahawk'
  1. MyFaces Tomahawk
  2. TOMAHAWK-1306

Focus2 postback problem

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.7-SNAPSHOT
    • 1.1.8
    • New Component
    • None
    • myfaces-1.2.4-SNAPSHOT
      tomahawk-sandbox12-1.1.7-SNAPSHOT
      tomahawk12-1.1.7-SNAPSHOT
      Tomcat 6.0.16

    Description

      Below are the main use cases for Focus2:
      1) if you first get to a page, the first input field should be highlighted
      2) if you post-back to a page and there is a validation-error, the
      first field with a validation error should be highlighted
      3) if you change a value on a form (e.g. a drop-down) and this
      changing a value initiates a postback, you will want the next field
      highlighted after the field that initiated the post-back to be
      highlighted

      Here are some bugs I've found:

      I) Focus2 cannot distinguish a newly created view (user first enters the webpage) from a postback (user does a submit and the same page gets loaded). See the attached testValueAttr.jsp to replicate the bug.

      What happens is that if you have the following tag in your code:
      <s:focus2 value="mainForm:email"/>
      Focus2 will give focus to the component succeeding mainForm:email. In the case of testValueAttr.jsp, it is mainForm:country. In the focus2.HtmlFocusRenderer.getFocusForId(), it always assumes that it is a postback.

      II) Focus2.HtmlFocusRenderer does not retrieve the submitted value in its decode() method. In the current implementation, HtmlFocusRenderer calls super.decode(context, component). I've checked and found out that after this line, the _submittedValue of the component is still null. _submittedValue should be the clientId of the currently focused input field maintained in a hidden field in your user's browser and updated by javascript for each focus event (See focus2.HtmlFocusRenderer.writeUpdateFocusScript()). Please see attached testPostBack.jsp to replicate the bug. Use case 3 fails here.

      The patch will fix both these bugs.

      Attachments

        1. webapp-files.rar
          2 kB
          Paul Rivera
        2. focus2.HtmlFocusRenderer-2.patch
          3 kB
          Paul Rivera
        3. focus2.HtmlFocusRenderer.patch
          4 kB
          Paul Rivera

        Activity

          People

            Unassigned Unassigned
            paulr1984 Paul Rivera
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: