[
https://issues.apache.org/jira/browse/TRINIDAD-2533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15141180#comment-15141180
]
Falco Wockenfuß commented on TRINIDAD-2533:
-------------------------------------------
Proposed Fix:
TrNumberFormat.prototype.removePrefixAndSuffix = function( inputText )
{
var positive = true;
if ( this._nPrefix && this._nPrefix != "" && inputText.indexOf(
this._nPrefix ) == 0 )
{
inputText = inputText.substr( this._nPrefix.length );
if ( this._nPrefix != this._pPrefix )
{
positive = false;
}
}
else if ( this._pPrefix && this._pPrefix != "" && inputText.indexOf(
this._pPrefix ) == 0 )
{
inputText = inputText.substr( this._pPrefix.length );
}
var nSuffix = this._nSuffix;
if( nSuffix && ( nSuffix.charAt( 0 ) == ' ' || nSuffix.charAt( 0 ) ==
'\xa0' ) )
{
nSuffix = nSuffix.substring( 1 );
}
var pSuffix = this._pSuffix;
if( pSuffix && ( pSuffix.charAt( 0 ) == ' ' || pSuffix.charAt( 0 ) ==
'\xa0' ) )
{
pSuffix = pSuffix.substring( 1 );
}
if ( nSuffix && nSuffix != "" && inputText.indexOf( nSuffix ) > 0 )
{
inputText = inputText.substr( 0, inputText.indexOf( nSuffix ) );
if ( nSuffix != pSuffix )
{
positive = false;
}
}
else if ( pSuffix && pSuffix != "" && inputText.indexOf( pSuffix ) > 0 )
{
inputText = inputText.substr( 0, inputText.indexOf( pSuffix ) );
}
var result = new Array( 2 );
result[ 0 ] = inputText;
result[ 1 ] = positive;
return result;
}
> TrNumberFormat doesn't parse native Numbers without Currency
> ------------------------------------------------------------
>
> Key: TRINIDAD-2533
> URL: https://issues.apache.org/jira/browse/TRINIDAD-2533
> Project: MyFaces Trinidad
> Issue Type: Bug
> Affects Versions: 2.0.0-beta-2
> Environment: Oracle ADF
> Reporter: Falco Wockenfuß
>
> If you enter a Number in a Currency-Field with a decimal separator (other
> than ".") and without trailing currency symbol you get a parse Error.
> Test Case - Type in JS Console:
> var tr = new TrNumberConverter( null, "currency", "de_DE" );
> tr.getAsObject( "20,50" ); // Parse Error
> tr.getAsObject( "20,50 €" ); // Working
> tr.getAsObject( "20" ); // Working
> Cause:
> The Method TrNumberFormat.prototype.removePrefixAndSuffix will fail, if not
> both matching Prefix and Suffix for Positive or Negative are present. If only
> one of both is present an exception is thrown and parsing fails.
> Since the Prefix for positive Currency is "" (the empty string) it will
> always match and try to find the matching suffix "€" or fail.
> In the case of an exception the default parseFloat is used as a fallback,
> which works for default english notation, so plain Numbers and using the dot
> as a decimal separator will work.
> Expected Behaviour and proposed Fix:
> Entering a locale Numberformat without Currency Symbol should be parsed
> without giving an error. The removePrefixAndSuffix Method should be more
> lenient and also accept input without currency suffix.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)