You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Volodymyr Siedlecki (Jira)" <de...@myfaces.apache.org> on 2022/11/22 15:20:00 UTC
[jira] [Created] (MYFACES-4508) Ignore ParsePosition when setParseIntegerOnly is true
Volodymyr Siedlecki created MYFACES-4508:
--------------------------------------------
Summary: Ignore ParsePosition when setParseIntegerOnly is true
Key: MYFACES-4508
URL: https://issues.apache.org/jira/browse/MYFACES-4508
Project: MyFaces Core
Issue Type: Bug
Affects Versions: 4.0.0-RC2, 2.3-next-M7
Reporter: Volodymyr Siedlecki
Background Issue: https://issues.apache.org/jira/browse/MYFACES-3196
In the issue linked above, MyFaces was updated to check the ParsePosition after parsing. If the ParsePosition index differed from the length of the input, then that meant part of the string was not iterated though and there was likely a problem.
However this can become another issue when setParseIntegerOnly is set to true because it leaves the index just after the decimal point. See the example in the text.
[The documentation state:|https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/text/NumberFormat.html]
setParseIntegerOnly : only affects parsing, e.g. if true, "3456.78" → 3456 (and leaves the parse position just after index 6) if false, "3456.78" → 3456.78 (and leaves the parse position just after index 8) This is independent of formatting. If you want to not show a decimal point where there might be no digits after the decimal point, use setDecimalSeparatorAlwaysShown.
This can unnecessarily throw a ParseException here: [https://github.com/apache/myfaces/blob/e74edfdbfb0b666e7b6b065dfce2c81899ea1cc7/api/src/main/java/jakarta/faces/convert/NumberConverter.java#L204]
While we can check for a decimal separator, but it differs between the various locales. I think it best to ignore the ParsePosition here when setParseIntegerOnly is true.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)