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/12/16 21:34:00 UTC

[jira] [Comment Edited] (MYFACES-4508) Handle ParsePosition when setParseIntegerOnly is true

    [ https://issues.apache.org/jira/browse/MYFACES-4508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17644832#comment-17644832 ] 

Volodymyr Siedlecki edited comment on MYFACES-4508 at 12/16/22 9:33 PM:
------------------------------------------------------------------------

Yes, I will soon -  I'll make a reminder for myself. 

https://github.com/apache/myfaces/pull/431 


was (Author: volosied):
Yes, I will soon -  I'll make a reminder for myself. 

> Handle 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: 2.3-next-M7, 4.0.0-RC2
>            Reporter: Volodymyr Siedlecki
>            Assignee: Volodymyr Siedlecki
>            Priority: Major
>             Fix For: 2.3-next-M8, 4.0.0-RC3
>
>
> 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)