Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.1.7-SNAPSHOT
-
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.