From adffaces-commits-return-1249-apmail-incubator-adffaces-commits-archive=incubator.apache.org@incubator.apache.org Mon Nov 06 08:21:10 2006 Return-Path: Delivered-To: apmail-incubator-adffaces-commits-archive@locus.apache.org Received: (qmail 94040 invoked from network); 6 Nov 2006 08:21:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Nov 2006 08:21:10 -0000 Received: (qmail 64724 invoked by uid 500); 6 Nov 2006 08:21:21 -0000 Delivered-To: apmail-incubator-adffaces-commits-archive@incubator.apache.org Received: (qmail 64699 invoked by uid 500); 6 Nov 2006 08:21:21 -0000 Mailing-List: contact adffaces-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: adffaces-dev@incubator.apache.org Delivered-To: mailing list adffaces-commits@incubator.apache.org Received: (qmail 64684 invoked by uid 99); 6 Nov 2006 08:21:21 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Nov 2006 00:21:21 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Nov 2006 00:21:08 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id E930B1A9846; Mon, 6 Nov 2006 00:20:41 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r471663 - /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js Date: Mon, 06 Nov 2006 08:20:41 -0000 To: adffaces-commits@incubator.apache.org From: matzew@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20061106082041.E930B1A9846@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: matzew Date: Mon Nov 6 00:20:40 2006 New Revision: 471663 URL: http://svn.apache.org/viewvc?view=rev&rev=471663 Log: TrRangeValidator overhaul Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js?view=diff&rev=471663&r1=471662&r2=471663 ============================================================================== --- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js (original) +++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js Mon Nov 6 00:20:40 2006 @@ -93,24 +93,30 @@ label ) { - - // This should probably do more than call decimalParse! - // the following line is needed because what's being passed - // into the validator is a number, and _decimalParse expects a string. - numberString = "" + value; - try + string = "" + value; + numberValue = parseFloat(string); + + if(numberValue >= this._minValue && numberValue <= this._maxValue) { - return _decimalParse(numberString, - this._messages, - this._maxPrecision, - this._maxScale, - this._maxValue, - this._minValue, - label); + return string; } - catch (e) + else { - throw new TrValidatorException(e.getFacesMessage()); + if(numberValue>this._maxValue) + { + facesMessage = _createFacesMessage(this._messages[(TrNumberConverter.LV+ '_S')], + this._messages[TrNumberConverter.LV], + label, + string); + } + else + { + facesMessage = _createFacesMessage(this._messages[(TrNumberConverter.MV+ '_S')], + this._messages[TrNumberConverter.MV], + label, + string); + } + throw new TrConverterException(facesMessage); } } @@ -139,9 +145,6 @@ ) { - // This should probably do more than call decimalParse! - // the following line is needed because what's being passed - // into the validator is a number, and _decimalParse expects a string. string = "" + value; length = string.length; @@ -344,38 +347,37 @@ if (sepIndex != -1) { integerDigits = sepIndex; - fractionDigits = numberString.length - sepIndex -1; + fractionDigits = parseInt(numberString.length - parseInt(sepIndex -1)); } var messageKey; - - if ((maxValue != (void 0)) && + if ((maxValue != null) && (result > maxValue)) { messageKey = TrNumberConverter.LV; } - else if ((minValue != (void 0)) && + else if ((minValue != null) && (result < minValue)) { messageKey = TrNumberConverter.MV; } - else if ((maxPrecision != (void 0)) && + else if ((maxPrecision != null) && (integerDigits > maxPrecision)) { messageKey = TrNumberConverter.LID; } - else if ((maxScale != (void 0)) && + + else if ((maxScale != null) && (fractionDigits > maxScale)) { messageKey = TrNumberConverter.LFD; } - if (messageKey != (void 0)) + if (messageKey != null) { var messages = messages; - - if ((messages == (void 0)) || - (messages[messageKey] == (void 0))) + if ((messages == null) || + (messages[messageKey] == null)) throw new TrConverterException(null, null, "Conversion failed, but no appropriate message found"); // default error format else {