Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 2.0.0, 2.0.0-EE-Beta1
-
Fix Version/s: 2.0.1
-
Component/s: ICE-Components
-
Labels:None
-
Environment:IE7/8
-
Workaround Exists:Yes
-
Workaround Description:Use onkeydown instead of onkeypress.
Description
<ice:inputText onkeypress="return numbersonly(this, event);"/>
The javascript solution can be found here: http://www.htmlcodetutorial.com/forms/index_famsupp_158.html. This solution works in 1.8.2 P02 and a stock JSF 2.0 example on FF and IE. However, this does not work in 2.0 or 2.0 EE Beta with IE7 or 8. It does work in FF.
The workaround is to use onkeydown but the customer has mentioned that they have existing logic in this event.
2.0 EE Beta (sc9836_IF2.war) and stock JSF 2 (case9836Example.war) test cases are attached.
-
- caps.js
- 1 kB
- Mircea Toma
-
Hide
- Case9836Example.war
- 2.31 MB
- Tyler Johnson
-
- META-INF/MANIFEST.MF 0.1 kB
- META-INF/context.xml 0.1 kB
- WEB-INF/lib/jsf-api.jar 580 kB
- WEB-INF/lib/jsf-impl.jar 1.74 MB
- WEB-INF/web.xml 1.0 kB
- caps.js 2 kB
- index.xhtml 0.6 kB
-
Hide
- sc9836_IF2.war
- 5.93 MB
- Tyler Johnson
-
- META-INF/MANIFEST.MF 0.0 kB
- ICEfacesPage1.xhtml 1 kB
- WEB-INF/faces-config.xml 0.3 kB
- WEB-INF/lib/commons-beanutils.jar 226 kB
- WEB-INF/lib/commons-digester.jar 140 kB
- WEB-INF/lib/commons-logging.jar 52 kB
- WEB-INF/lib/icefaces-ee-compat.jar 2.60 MB
- WEB-INF/lib/icefaces-ee-ext.jar 56 kB
- WEB-INF/lib/icefaces-ee.jar 200 kB
- WEB-INF/lib/jsf-api.jar 603 kB
- WEB-INF/lib/jsf-impl.jar 1.82 MB
- WEB-INF/lib/jstl.jar 20 kB
- WEB-INF/lib/jxl.jar 708 kB
- WEB-INF/web.xml 2 kB
- caps.js 0.9 kB
- index.jsp 0.1 kB
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
The reason why the default action is not canceled seems to be caused by the way IE evaluates the inlined event handler code.
In the rendered markup the 'keypress' event handler looks like this:
onkeypress="return numbersonly(this, event); iceSubmit(form,this,event);"
In Firefox/Safari the first statement is evaluated, normally the second statement is not reachable but it seems that these browsers choose to evaluate the remaining statements as well. The proof is that when 'Enter' is pressed the iceSubmit() function is executed. The value returned by numbersonly() is returned back to the browser.
In IE the both statements are executed as well but the event handler code doesn't return the numbersonly() return value since it 's not the last statement.
So, the solution to this issue is to cancel the default action using preventDefault/returnValue API since controlling the order of statements in the in the inline event handler is not possible (iceSubmit(...) will always be rendered last).
To completely solve the issue the caps.js code needs to be replaced with the attached version and ice:inputText's onkeypress attribute needs to be modified as follows:
<ice:inputText id="step1DriverSSNP1IPText" onkeypress="numbersonly(this, event);"/>
The attached caps.js file contains a modified definition for numbersonly() function. The function cancels the default action for the event internally, invoking either event.preventDefault() function in Firefox/Safari/Opera or sets the event.returnValue property to false in case of IE.