-
Bug
-
Resolution: Fixed
-
Normal
-
8.6.1
-
Security Level: Jimmy
-
None
-
reproduced with openJDK 11 (https://jdk.java.net/11/)
AdoptOpenJDK 11.0.2 (https://adoptopenjdk.net/?variant=openjdk11&jvmVariant=hotspot)
-
ZK 8.6.2 S1, ZK 8.6.2 S2
-
None
Steps to Reproduce
<vlayout> No locale: <intbox value="-123"/> en_US: <intbox locale="en_US" value="-123"/> sv_SE: <intbox locale="sv_SE" value="-123"/> </vlayout>
Try typing a minus character into the int boxes.
Current Result
For the intbox with swedish locale the MINUS key (numpad and normal keyboard) is ignored
Expected Result
Possible to type negative numbers
Allow using the minus key on a keyboard to type in negative numbers.
Debug Info
Looking closely at the swedish Intbox you'll see the MINUS character is not a HYPHEN-MINUS (code 0x2d) but a unicode MINUS (code \u2212)
Root Cause
Since JDK 9 the default locale DB was changed to CLDR (http://openjdk.java.net/jeps/252).
Which defines the unicode MINUS as the minusSign for various locales (including swedish)
https://www.unicode.org/cldr/charts/33/by_type/numbers.symbols.html#2f08b5ebf85e1e8b
(most locales still use the HYPHEN-MINUS code 0x2d)
Workaround
- https://bugs.openjdk.java.net/browse/JDK-8214926 mentions a possibility to change the default locale provider to be compatible with JDK8 by specifying a JVM startup argument:
-Djava.locale.providers=COMPAT,CLDR
- alternative in ZK: In order to allow both characters override the getAllowedKeys_ function for NumberInputWidgets
<script><![CDATA[ /*Patch for ZK-4277*/ zk.afterLoad('zul.inp', function() { var xNumberInputWidget = {}; zk.override(zul.inp.NumberInputWidget.prototype, xNumberInputWidget, { getAllowedKeys_ : function() { return xNumberInputWidget.getAllowedKeys_.apply(this, arguments) + '-'; } });//zk.override });//zk.afterLoad ]]></script>
This happens to work, as the number parser will replace the localized MINUS character with a HYPHEN-MINUS anyway, so that allowing to type it doesn't change the parsed result.