You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2007/08/07 10:47:15 UTC
svn commit: r563426 - in
/myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main:
java/org/apache/myfaces/trinidadinternal/convert/
java/org/apache/myfaces/trinidadinternal/resource/
javascript/META-INF/adf/jsLibs/
Author: matzew
Date: Tue Aug 7 01:47:13 2007
New Revision: 563426
URL: http://svn.apache.org/viewvc?view=rev&rev=563426
Log:
merged some client number converter related fixes to TMP branch
Added:
myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberConverter.js
myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/TrCollections.js
Modified:
myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/NumberConverter.java
myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java
myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js
Modified: myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/NumberConverter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/NumberConverter.java?view=diff&rev=563426&r1=563425&r2=563426
==============================================================================
--- myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/NumberConverter.java (original)
+++ myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/NumberConverter.java Tue Aug 7 01:47:13 2007
@@ -124,7 +124,7 @@
boolean formating = _formatingAttributesSet();
if(formating)
- params = new Object[10];
+ params = new Object[12];
else
params = new Object[4];
params[0] = this.getPattern();
@@ -136,12 +136,14 @@
//only if specified.
if(formating)
{
- params[4] = this.getCurrencyCode();
- params[5] = this.getCurrencySymbol();
- params[6] = this.isMaximumFractionDigitsSet() ? this.getMaxFractionDigits() : null;
- params[7] = this.isMaximumIntegerDigitsSet() ? this.getMaxIntegerDigits() : null;
- params[8] = this.isMinimumFractionDigitsSet() ? this.getMinFractionDigits() : null;
- params[9] = this.isMinimumIntegerDigitsSet() ? this.getMinIntegerDigits() : null;
+ params[4] = this.isIntegerOnly();
+ params[5] = this.isGroupingUsed();
+ params[6] = this.getCurrencyCode();
+ params[7] = this.getCurrencySymbol();
+ params[8] = this.isMaximumFractionDigitsSet() ? this.getMaxFractionDigits() : null;
+ params[9] = this.isMaximumIntegerDigitsSet() ? this.getMaxIntegerDigits() : null;
+ params[10] = this.isMinimumFractionDigitsSet() ? this.getMinFractionDigits() : null;
+ params[11] = this.isMinimumIntegerDigitsSet() ? this.getMinIntegerDigits() : null;
}
return params;
@@ -155,6 +157,8 @@
{
return (this.getCurrencyCode()!=null ||
this.getCurrencySymbol() != null ||
+ this.isGroupingUsed() != true ||
+ this.isIntegerOnly() != false ||
this.isMaximumFractionDigitsSet() ||
this.isMaximumIntegerDigitsSet() ||
this.isMinimumFractionDigitsSet() ||
@@ -166,10 +170,9 @@
UIComponent component,
Map<?, ?> messages)
{
-
StringBuilder outBuffer = new StringBuilder(250);
- if(this.isIntegerOnly() && this.getPattern() == null)
+ if(this.isIntegerOnly() && this.getPattern() == null && "number".equals(this.getType()))
{
outBuffer.append("new TrIntegerConverter(");
outBuffer.append("null,null,0,");
Modified: myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java?view=diff&rev=563426&r1=563425&r2=563426
==============================================================================
--- myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java (original)
+++ myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/resource/CoreCommonScriptsResourceLoader.java Tue Aug 7 01:47:13 2007
@@ -56,7 +56,9 @@
{
"META-INF/adf/jsLibs/CharSets.js",
"META-INF/adf/jsLibs/NumberFormat.js",
+ "META-INF/adf/jsLibs/NumberConverter.js",
"META-INF/adf/jsLibs/CoreFormat.js",
+ "META-INF/adf/jsLibs/TrCollections.js",
"META-INF/adf/jsLibs/DateField.js",
"META-INF/adf/jsLibs/DateFieldFormat.js",
"META-INF/adf/jsLibs/DateFormat.js",
@@ -77,6 +79,8 @@
{
"META-INF/adf/jsLibsDebug/CharSets.js",
"META-INF/adf/jsLibsDebug/NumberFormat.js",
+ "META-INF/adf/jsLibsDebug/NumberConverter.js",
+ "META-INF/adf/jsLibsDebug/TrCollections.js",
"META-INF/adf/jsLibsDebug/CoreFormat.js",
"META-INF/adf/jsLibsDebug/DateField.js",
"META-INF/adf/jsLibsDebug/DateFieldFormat.js",
Modified: myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js?view=diff&rev=563426&r1=563425&r2=563426
==============================================================================
--- myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js (original)
+++ myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js Tue Aug 7 01:47:13 2007
@@ -16,194 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-/**
- * constructor of client side NumberConverter class
- */
-function TrNumberConverter(
- pattern,
- type,
- locale,
- messages,
- currencyCode,
- currencySymbol,
- maxFractionDigits,
- maxIntegerDigits,
- minFractionDigits,
- minIntegerDigits)
-{
- this._pattern = pattern;
- this._type = type;
- this._locale = locale;
- this._messages = messages;
- this._currencyCode = currencyCode;
- this._currencySymbol = currencySymbol;
- this._maxFractionDigits = maxFractionDigits;
- this._maxIntegerDigits = maxIntegerDigits;
- this._minFractionDigits = minFractionDigits;
- this._minIntegerDigits = minIntegerDigits;
-
- // for debugging
- this._class = "TrNumberConverter";
-
- if(this._type=="percent")
- {
- this._example = 0.3423;
- this._numberFormat = TrNumberFormat.getPercentInstance();
- }
- else if(this._type=="currency")
- {
- this._example = 10250;
- this._numberFormat = TrNumberFormat.getCurrencyInstance();
- }
-}
-
-TrNumberConverter.prototype = new TrConverter();
-
-/**
- * Checks if this converter can convert the value, which
- * is only true, if no pattern is set and the type is a number
- */
-TrNumberConverter.prototype._isConvertible = function()
-{
- if((this._pattern == null) && (this._locale == null))
- {
- return true;
- }
- else
- {
- return false;
- }
-}
-TrNumberConverter.prototype.getFormatHint = function()
-{
- if(this._messages && this._messages["hintPattern"])
- {
- return TrMessageFactory.createCustomMessage(
- this._messages["hintPattern"],
- this._pattern);
- }
- else
- {
- if(this._pattern)
- {
- return TrMessageFactory.createMessage(
- "org.apache.myfaces.trinidad.convert.NumberConverter.FORMAT_HINT",
- this._pattern);
- }
- else
- {
- return null;
- }
- }
-}
-
-/**
- * Returns the number value as string or undefined (see also _isConvertible).
- */
-TrNumberConverter.prototype.getAsString = function(
- number,
- label
- )
-{
- if(this._isConvertible())
- {
- if(this._type=="percent" || this._type=="currency")
- {
- var string = this._numberFormat.format(number);
- if(this._type=="currency")
- {
- //In Trinidad the currencyCode gets preference over currencySymbol
- //this is similar on the server-side
- if(this._currencyCode)
- {
- string = string.replace(getLocaleSymbols().getCurrencyCode(), this._currencyCode);
- }
- else if(this._currencySymbol)
- {
- string = string.replace(getLocaleSymbols().getCurrencySymbol(), this._currencySymbol);
- }
- }
- return string;
- }
- else
- {
- this._numberFormat = TrNumberFormat.getNumberInstance();
- this._numberFormat.setMaximumFractionDigits(this._maxFractionDigits);
- this._numberFormat.setMaximumIntegerDigits(this._maxIntegerDigits);
- this._numberFormat.setMinimumFractionDigits( this._minFractionDigits);
- this._numberFormat.setMinimumIntegerDigits( this._minIntegerDigits);
- return this._numberFormat.format(number);
-
- //return "" + number;
- }
- }
- else
- {
- return undefined;
- }
-}
-
-/**
- * Returns the number value for the submitted string or undefined (see also _isConvertible).
- */
-TrNumberConverter.prototype.getAsObject = function(
- numberString,
- label
- )
-{
- if(this._isConvertible())
- {
- var parsedValue;
- if(this._type=="percent" || this._type=="currency")
- {
- try
- {
- numberString = this._numberFormat.parse(numberString)+"";
- }
- catch(e)
- {
- var facesMessage;
- var example = this._numberFormat.format(this._example);
- var key = "org.apache.myfaces.trinidad.convert.NumberConverter.CONVERT_" + this._type.toUpperCase();
- if(this._messages && this._messages[this._type])
- {
- facesMessage = _createCustomFacesMessage(TrMessageFactory.getSummaryString(key),
- this._messages[this._type],
- label,
- numberString,
- example);
- }
- else
- {
- facesMessage = _createFacesMessage(key,
- label,
- numberString,
- example);
- }
- throw new TrConverterException(facesMessage);
- }
- }
- parsedValue = _decimalParse(numberString,
- this._messages,
- "org.apache.myfaces.trinidad.convert.NumberConverter",
- null,
- null,
- null,
- null,
- label,
- true);
- if(this._type=="percent")
- {
- parsedValue = parsedValue / 100;
- }
- return parsedValue;
- }
- else
- {
- return undefined;
- }
-}
function TrIntegerConverter(
message,
@@ -912,8 +724,8 @@
var allMonth = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];
//remove the submitted values, which are invalid, to display only the valid ones
- this._removeInvalidValues(this._weekdaysValue, allWeekdays);
- this._removeInvalidValues(this._monthValue, allMonth);
+ TrCollections.removeValuesFromArray(this._weekdaysValue, allWeekdays);
+ TrCollections.removeValuesFromArray(this._monthValue, allMonth);
return _returnHints(
this._messages,
@@ -926,31 +738,6 @@
);
}
-/**
- * Removes invalidValues from the allValues array
- * TODO matzew: move this to a "CollectionUtil.js" ?
- */
-TrDateRestrictionValidator.prototype._removeInvalidValues = function(
- invalidValues,
- allValues
- )
-{
- if(invalidValues)
- {
- for(i=0; i<invalidValues.length; i++)
- {
- var value = invalidValues[i];
- for(j=0;j<allValues.length; j++)
- {
- if(allValues[j].toLowerCase() == value.toLowerCase())
- {
- allValues.splice(j,1);
- }
- }
- }
- }
-}
-
TrDateRestrictionValidator.prototype._translate = function(
values,
map,
@@ -988,7 +775,7 @@
if(weekDaysArray[i].toLowerCase() == dayString)
{
var allWeekdays = ['mon','tue','wed','thu','fri','sat','sun'];
- this._removeInvalidValues(this._weekdaysValue, allWeekdays);
+ TrCollections.removeValuesFromArray(this._weekdaysValue, allWeekdays);
var days = this._translate(allWeekdays, this._translatedWeekdaysMap, converter.getLocaleSymbols().getWeekdays());
var facesMessage;
@@ -1023,7 +810,7 @@
if(monthArray[i].toLowerCase() == monthString)
{
var allMonth = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'];
- this._removeInvalidValues(this._monthValue, allMonth);
+ TrCollections.removeValuesFromArray(this._monthValue, allMonth);
var month = this._translate(allMonth, this._translatedMonthMap, converter.getLocaleSymbols().getMonths());
var facesMessage;
Added: myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberConverter.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberConverter.js?view=auto&rev=563426
==============================================================================
--- myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberConverter.js (added)
+++ myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberConverter.js Tue Aug 7 01:47:13 2007
@@ -0,0 +1,313 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * constructor of client side NumberConverter class
+ */
+function TrNumberConverter(
+ pattern,
+ type,
+ locale,
+ messages,
+ integerOnly,
+ groupingUsed,
+ currencyCode,
+ currencySymbol,
+ maxFractionDigits,
+ maxIntegerDigits,
+ minFractionDigits,
+ minIntegerDigits)
+{
+ this._pattern = pattern;
+ this._type = type;
+ this._locale = locale;
+ this._messages = messages;
+ this._currencyCode = currencyCode;
+ this._currencySymbol = currencySymbol;
+ this._maxFractionDigits = maxFractionDigits;
+ this._maxIntegerDigits = maxIntegerDigits;
+ this._minFractionDigits = minFractionDigits;
+ this._minIntegerDigits = minIntegerDigits;
+
+ //set the integerOnly value
+ if(integerOnly !== undefined)
+ this._integerOnly = integerOnly;
+ else
+ this._integerOnly = false;
+
+ //set the groupingUsed value
+ if(groupingUsed !== undefined)
+ this._groupingUsed = groupingUsed;
+ else
+ this._groupingUsed = true;
+
+ //init the TrNumberFormat
+ this._initNumberFormat();
+
+ // for debugging
+ this._class = "TrNumberConverter";
+
+}
+
+TrNumberConverter.prototype = new TrConverter();
+
+//***********************
+// PUBLIC
+//***********************
+
+TrNumberConverter.prototype.setCurrencyCode = function(currencyCode)
+{
+ this._currencyCode = currencyCode;
+}
+TrNumberConverter.prototype.getCurrencyCode = function()
+{
+ return this._currencyCode;
+}
+TrNumberConverter.prototype.setCurrencySymbol = function(currencySymbol)
+{
+ this._currencySymbol = currencySymbol;
+}
+TrNumberConverter.prototype.getCurrencySymbol = function()
+{
+ return this._currencySymbol;
+}
+
+TrNumberConverter.prototype.setMaxFractionDigits = function(maxFractionDigits)
+{
+ this._maxFractionDigits = maxFractionDigits;
+}
+TrNumberConverter.prototype.getMaxFractionDigits = function()
+{
+ return this._maxFractionDigits;
+}
+
+TrNumberConverter.prototype.setMaxIntegerDigits = function(maxIntegerDigits)
+{
+ this._maxIntegerDigits = maxIntegerDigits;
+}
+TrNumberConverter.prototype.getMaxIntegerDigits = function()
+{
+ return this._maxIntegerDigits ;
+}
+
+TrNumberConverter.prototype.setMinFractionDigits = function(minFractionDigits)
+{
+ this._minFractionDigits = minFractionDigits;
+}
+TrNumberConverter.prototype.getMinFractionDigits = function()
+{
+ return this._minFractionDigits;
+}
+
+TrNumberConverter.prototype.setMinIntegerDigits = function(minIntegerDigits)
+{
+ this._minIntegerDigits = minIntegerDigits;
+}
+TrNumberConverter.prototype.getMinIntegerDigits = function()
+{
+ return this._minIntegerDigits;
+}
+
+TrNumberConverter.prototype.setGroupingUsed = function(groupingUsed)
+{
+ this._groupingUsed = groupingUsed;
+}
+TrNumberConverter.prototype.isGroupingUsed = function()
+{
+ return this._groupingUsed;
+}
+
+TrNumberConverter.prototype.setIntegerOnly = function(integerOnly)
+{
+ this._integerOnly = integerOnly;
+}
+TrNumberConverter.prototype.isIntegerOnly = function()
+{
+ return this._integerOnly;
+}
+
+TrNumberConverter.prototype.getFormatHint = function()
+{
+ if(this._messages && this._messages["hintPattern"])
+ {
+ return TrMessageFactory.createCustomMessage(
+ this._messages["hintPattern"],
+ this._pattern);
+ }
+ else
+ {
+ if(this._pattern)
+ {
+ return TrMessageFactory.createMessage(
+ "org.apache.myfaces.trinidad.convert.NumberConverter.FORMAT_HINT",
+ this._pattern);
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
+
+/**
+ * Returns the number value as string or undefined (see also _isConvertible).
+ */
+TrNumberConverter.prototype.getAsString = function(
+ number,
+ label
+ )
+{
+ if(this._isConvertible())
+ {
+ if(this._type=="percent" || this._type=="currency")
+ {
+ var string = this._numberFormat.format(number);
+ if(this._type=="currency")
+ {
+ //In Trinidad the currencyCode gets preference over currencySymbol
+ //this is similar on the server-side
+ if(this._currencyCode)
+ {
+ string = string.replace(getLocaleSymbols().getCurrencyCode(), this._currencyCode);
+ }
+ else if(this._currencySymbol)
+ {
+ string = string.replace(getLocaleSymbols().getCurrencySymbol(), this._currencySymbol);
+ }
+ }
+ return string;
+ }
+ else
+ {
+ return this._numberFormat.format(number);
+ }
+ }
+ else
+ {
+ return undefined;
+ }
+}
+
+/**
+ * Returns the number value for the submitted string or undefined (see also _isConvertible).
+ */
+TrNumberConverter.prototype.getAsObject = function(
+ numberString,
+ label
+ )
+{
+ if(this._isConvertible())
+ {
+ var parsedValue;
+ if(this._type=="percent" || this._type=="currency")
+ {
+ try
+ {
+ numberString = this._numberFormat.parse(numberString)+"";
+ }
+ catch(e)
+ {
+ var facesMessage;
+ var example = this._numberFormat.format(this._example);
+ var key = "org.apache.myfaces.trinidad.convert.NumberConverter.CONVERT_" + this._type.toUpperCase();
+ if(this._messages && this._messages[this._type])
+ {
+ facesMessage = _createCustomFacesMessage(TrMessageFactory.getSummaryString(key),
+ this._messages[this._type],
+ label,
+ numberString,
+ example);
+ }
+ else
+ {
+ facesMessage = _createFacesMessage(key,
+ label,
+ numberString,
+ example);
+ }
+ throw new TrConverterException(facesMessage);
+ }
+ }
+ parsedValue = _decimalParse(numberString,
+ this._messages,
+ "org.apache.myfaces.trinidad.convert.NumberConverter",
+ null,
+ null,
+ null,
+ null,
+ label,
+ !this.isIntegerOnly());
+ if(this._type=="percent")
+ {
+ parsedValue = parsedValue / 100;
+ }
+ return parsedValue;
+ }
+ else
+ {
+ return undefined;
+ }
+}
+
+//***********************
+// PRIVATE
+//***********************
+
+/**
+ * Checks if this converter can convert the value, which
+ * is only true, if no pattern is set and the type is a number
+ */
+TrNumberConverter.prototype._isConvertible = function()
+{
+ if((this._pattern == null) && (this._locale == null))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+/**
+ * runs the creation of the used TrNumberFormat class
+ */
+TrNumberConverter.prototype._initNumberFormat = function()
+{
+ if(this._type=="percent")
+ {
+ this._example = 0.3423;
+ this._numberFormat = TrNumberFormat.getPercentInstance();
+ }
+ else if(this._type=="currency")
+ {
+ this._example = 10250;
+ this._numberFormat = TrNumberFormat.getCurrencyInstance();
+ }
+ else if(this._type=="number")
+ {
+ this._numberFormat = TrNumberFormat.getNumberInstance();
+ }
+
+ this._numberFormat.setGroupingUsed(this.isGroupingUsed());
+ this._numberFormat.setMaximumFractionDigits(this.getMaxFractionDigits());
+ this._numberFormat.setMaximumIntegerDigits(this.getMaxIntegerDigits());
+ this._numberFormat.setMinimumFractionDigits(this.getMinFractionDigits());
+ this._numberFormat.setMinimumIntegerDigits(this.getMinIntegerDigits());
+}
\ No newline at end of file
Modified: myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js?view=diff&rev=563426&r1=563425&r2=563426
==============================================================================
--- myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js (original)
+++ myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/NumberFormat.js Tue Aug 7 01:47:13 2007
@@ -29,11 +29,13 @@
this._pSuf = getLocaleSymbols().getPositiveSuffix();
this._nPre = getLocaleSymbols().getNegativePrefix();
this._nSuf = getLocaleSymbols().getNegativeSuffix();
- //default values, similar to JDK
+
+ //default values, similar to JDK (values from Apache Harmony)
this._maxFractionDigits = 3;
this._maxIntegerDigits = 40;
this._minFractionDigits = 0;
this._minIntegerDigits = 1;
+ this._groupingUsed = true;
}
//***********************
@@ -65,6 +67,28 @@
}
/**
+ * Sets whether this NumberFormat formats and parses numbers using a
+ * grouping separator.
+ *
+ * @param value true when a grouping separator is used, false otherwise
+ */
+TrNumberFormat.prototype.setGroupingUsed = function(groupingUsed)
+{
+ this._groupingUsed = groupingUsed;
+}
+
+/**
+ * Answers whether this NumberFormat formats and parses numbers using a
+ * grouping separator.
+ *
+ * @return true when a grouping separator is used, false otherwise
+ */
+TrNumberFormat.prototype.isGroupingUsed = function()
+{
+ return this._groupingUsed;
+}
+
+/**
* Used to specify the new maximum count of integer digits that are printed
* when formatting. If the maximum is less than the number of integer
* digits, the most significant digits are truncated.
@@ -76,7 +100,7 @@
//taken from the Apache Harmony project
if(number)
{
- this._maxIntegerDigits = value < 0 ? 0 : number;
+ this._maxIntegerDigits = number < 0 ? 0 : number;
if (this._minIntegerDigits > this._maxIntegerDigits)
{
this._minIntegerDigits = this._maxIntegerDigits;
@@ -109,7 +133,7 @@
//taken from the Apache Harmony project
if(number)
{
- this._maxFractionDigits = value < 0 ? 0 : number;
+ this._maxFractionDigits = number < 0 ? 0 : number;
if (this._maxFractionDigits < this._minFractionDigits)
{
this._minFractionDigits = this._maxFractionDigits;
@@ -141,7 +165,7 @@
//taken from the Apache Harmony project
if(number)
{
- this._minIntegerDigits = value < 0 ? 0 : number;
+ this._minIntegerDigits = number < 0 ? 0 : number;
if(this._minIntegerDigits > this._maxIntegerDigits)
{
this._maxIntegerDigits = this._minIntegerDigits;
@@ -172,7 +196,7 @@
//taken from the Apache Harmony project
if(number)
{
- this._minFractionDigits = value < 0 ? 0 : number;
+ this._minFractionDigits = number < 0 ? 0 : number;
if (this._maxFractionDigits < this._minFractionDigits)
{
this._maxFractionDigits = this._minFractionDigits;
@@ -466,8 +490,11 @@
ints = leadingZeros + ints;
}
- ints = this._addGroupingSeparators(ints);
-
+ if(this.isGroupingUsed())
+ {
+ ints = this._addGroupingSeparators(ints);
+ }
+
return ints;
}
Added: myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/TrCollections.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/TrCollections.js?view=auto&rev=563426
==============================================================================
--- myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/TrCollections.js (added)
+++ myfaces/trinidad/branches/faces-1_2_1-070726/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/TrCollections.js Tue Aug 7 01:47:13 2007
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Utilities for working with collections
+ */
+var TrCollections = new Object();
+
+/**
+ * A static util function that removes an array of values
+ * from another array.
+ * @param {Array} toRemove Array that contains the values to remove
+ * @param {Array} allValues Array from that the values will be removed
+ */
+TrCollections.removeValuesFromArray = function(
+ toRemove,
+ allValues
+ )
+{
+ if(toRemove && allValues)
+ {
+ for(i=0; i<toRemove.length; i++)
+ {
+ var value = toRemove[i];
+ for(j=0;j<allValues.length; j++)
+ {
+ if(allValues[j].toLowerCase() == value.toLowerCase())
+ {
+ allValues.splice(j,1);
+ }
+ }
+ }
+ }
+}
+