modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/IsLongValidator.java | 13 ++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
New commits: commit 74d3e194811007373811bc1cdc8766b68f23de54 Author: Ian Springer ian.springer@redhat.com Date: Wed Dec 7 14:27:05 2011 -0500
[BZ 760721] fix bug where negative values would always get incorrectly normalized to "-" (https://bugzilla.redhat.com/show_bug.cgi?id=760721)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/IsLongValidator.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/IsLongValidator.java index cb61cab..2b25e73 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/IsLongValidator.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/form/IsLongValidator.java @@ -62,11 +62,16 @@ public class IsLongValidator extends CustomValidator { }
String baseStringValue = stripOffNegativeSignAndLeadingZeroes(stringValue, isNegative); - updateInputValue((isNegative) ? "-" : "" + baseStringValue); + String normalizedValue; + if (isNegative) { + normalizedValue = "-" + baseStringValue; + } else { + normalizedValue = baseStringValue; + } + updateInputValue(normalizedValue);
// all zeroes, optionally prefixed with negative sign, is valid - if (baseStringValue.length() == 0) { - updateInputValue("0"); + if (baseStringValue.equals("0")) { return true; }
@@ -107,7 +112,7 @@ public class IsLongValidator extends CustomValidator { charsToSkip++; }
- for (int i = charsToSkip; i < stringValue.length(); i++) { + for (int i = charsToSkip; i < stringValue.length() - 1; i++) { if (stringValue.charAt(i) == '0') { charsToSkip++; } else {
rhq-commits@lists.fedorahosted.org