Author: pyaschenko
Date: 2010-11-02 05:53:35 -0400 (Tue, 02 Nov 2010)
New Revision: 19884
Removed:
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/length.js
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/validator-length.js
Modified:
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/length-validator.js
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/BooleanConverterTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/ByteConverterTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/LengthValidatorTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/NumberConverterTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/ShortConverterTest.java
Log:
http://jira.jboss.com/jira/browse/RF-9329
http://jira.jboss.com/jira/browse/RF-9521
Modified:
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/length-validator.js
===================================================================
---
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/length-validator.js 2010-11-02
06:22:38 UTC (rev 19883)
+++
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/length-validator.js 2010-11-02
09:53:35 UTC (rev 19884)
@@ -5,7 +5,7 @@
throw rf.csv.getMessage(params.customMessage, 'LENGTH_VALIDATOR_MAXIMUM',
[params.maximum, componentId]);
}
if (params.minimum && value.length < params.minimum) {
- throw rf.csv.getMessage(params.customMessage, 'LENGTH_VALIDATOR_MINIMUM',
[params.maximum, componentId]);
+ throw rf.csv.getMessage(params.customMessage, 'LENGTH_VALIDATOR_MINIMUM',
[params.minimum, componentId]);
}
}
})(window.RichFaces || (window.RichFaces={}))
Deleted:
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/length.js
===================================================================
---
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/length.js 2010-11-02
06:22:38 UTC (rev 19883)
+++
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/length.js 2010-11-02
09:53:35 UTC (rev 19884)
@@ -1,78 +0,0 @@
-(function($, rf) {
-
- rf.csv = rf.csv || {};
-
- var _messages = {};
- var _validators = {};
- var _converters = {};
-
- var RE_MESSAGE_PATTERN = /\{(\d+)\}/g;
-
- $.extend(rf.csv, {
- // Messages API
- addMessage: function (messagesObject) {
- $.extend(_messages, messagesObject);
- },
- getMessage: function(customMessages, id, values) {
- var message = (customMessages && customMessages[id]) || _messages[id] ||
"";
- if (message) {
- var msgObject =
message.replace(RE_MESSAGE_PATTERN,"\n$1\n").split("\n");
- var value;
- for (var i=1; i<msgObject.length; i+=2) {
- value = values[msgObject[i]];
- msgObject[i] = typeof value == "undefined" ? "" : value;
- }
- message = msgObject.join('');
- }
- return message;
- },
- // Validators API
- addValidator: function (validatorFunctions) {
- $.extend(_validators, validatorFunctions);
- },
- validate: function (event, id, validatorList, messageComponentList, options) {
- var value;
- var element = rf.getDomElement(id);
- if (element.value) {
- value = element.value;
- } else {
- var component = rf.$(element);
- value = component && typeof component["getValue"] ==
"function" ? component.getValue() : "";
- }
- var result;
- var messageComponentsUpdated = false;
- var validatorFunction;
- for (var validator in validatorList) {
- validatorFunction = _validators[validator];
- if (validatorFunction) {
- result = validatorFunction(value, validatorList[validator]);
- }
- if (result && result.length>0) {
- messageComponentsUpdated = true;
- //updateMessageComponents(messageElementIds, result);
- alert(result);
- break;
- }
- }
- !messageComponentsUpdated && alert("no message from
validators");//updateMessageComponents(messageElementIds, "");
- },
- addFormValidators: function (formId, callValidatorFunctions) {
-
- }
- });
-})(jQuery, window.RichFaces || (window.RichFaces={}));
-
-
-RichFaces.csv.addValidator({"length":
-(function(rf) {
- return function (value, params) {
- var result = "";
- if (value.length<params.min) {
- result = rf.csv.getMessage(params.customMessages, 'LengthValidator.MINIMUM',
[params.min,value]);
- } else if (value.length>params.max){
- result = rf.csv.getMessage(params.customMessages, 'LengthValidator.MAXIMUM',
[params.max,value]);
- }
- return result;
- }
-})(window.RichFaces || (window.RichFaces={}))
-});
\ No newline at end of file
Deleted:
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/validator-length.js
===================================================================
---
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/validator-length.js 2010-11-02
06:22:38 UTC (rev 19883)
+++
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/validator-length.js 2010-11-02
09:53:35 UTC (rev 19884)
@@ -1,13 +0,0 @@
-RichFaces.csv.addValidator({"length":
-(function(rf) {
- return function (value, params) {
- var result = "";
- if (value.length<params.min) {
- result = rf.csv.getMessage(params.customMessages, 'LengthValidator.MINIMUM',
[params.min,value]);
- } else if (value.length>params.max){
- result = rf.csv.getMessage(params.customMessages, 'LengthValidator.MAXIMUM',
[params.max,value]);
- }
- return result;
- }
-})(window.RichFaces || (window.RichFaces={}))
-});
\ No newline at end of file
Modified:
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/BooleanConverterTest.java
===================================================================
---
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/BooleanConverterTest.java 2010-11-02
06:22:38 UTC (rev 19883)
+++
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/BooleanConverterTest.java 2010-11-02
09:53:35 UTC (rev 19884)
@@ -39,9 +39,19 @@
}
@Test
- @TestDataHolder(successes = { @TestData(submittedValue = "true"),
@TestData(submittedValue = "True"),
- @TestData(submittedValue = "TRUE"), @TestData(submittedValue =
"false"), @TestData(submittedValue = "0"),
- @TestData(submittedValue = "1"), @TestData(submittedValue =
"") }, failures = {})
+ @TestDataHolder(
+ successes = {
+ @TestData(submittedValue = "true"),
+ @TestData(submittedValue = "True"),
+ @TestData(submittedValue = "TRUE"),
+ @TestData(submittedValue = "false"),
+ @TestData(submittedValue = "0"),
+ @TestData(submittedValue = "1"),
+ @TestData(submittedValue = "")
+ },
+ failures = {}
+ )
+
public void testSuccess() throws Exception {
setClientFunction("RichFaces.csv.getConverter('boolean')");
setObjectId(BooleanConverter.CONVERTER_ID);
Modified:
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/ByteConverterTest.java
===================================================================
---
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/ByteConverterTest.java 2010-11-02
06:22:38 UTC (rev 19883)
+++
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/ByteConverterTest.java 2010-11-02
09:53:35 UTC (rev 19884)
@@ -39,10 +39,23 @@
}
@Test
- @TestDataHolder(successes = { @TestData(submittedValue = "-128"),
@TestData(submittedValue = "0"),
- @TestData(submittedValue = "127") }, failures = {
@TestData(submittedValue = "-129"),
- @TestData(submittedValue = "128"), @TestData(submittedValue =
"1.0"), @TestData(submittedValue = "1.2"),
- @TestData(submittedValue = "1a"), @TestData(submittedValue =
"aaa"), @TestData(submittedValue = "- 127") })
+ @TestDataHolder(
+ successes = {
+ @TestData(submittedValue = "-128"),
+ @TestData(submittedValue = "0"),
+ @TestData(submittedValue = "127")
+ },
+ failures = {
+ @TestData(submittedValue = "-129"),
+ @TestData(submittedValue = "128"),
+ @TestData(submittedValue = "1.0"),
+ @TestData(submittedValue = "1.2"),
+ @TestData(submittedValue = "1a"),
+ @TestData(submittedValue = "aaa"),
+ @TestData(submittedValue = "- 127")
+ }
+ )
+
public void testSuccess() throws Exception {
setClientFunction("RichFaces.csv.getConverter('byte')");
setObjectId(ByteConverter.CONVERTER_ID);
Modified:
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java
===================================================================
---
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java 2010-11-02
06:22:38 UTC (rev 19883)
+++
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/DateTimeConverterTest.java 2010-11-02
09:53:35 UTC (rev 19884)
@@ -38,11 +38,16 @@
}
@Test
- @TestDataHolder(successes = { @TestData(submittedValue = "18-10-2010")
- // ,@TestData(submittedValue = "17-10-2010")
- }, failures = {
- // @TestData(submittedValue = "10/17/2010")
- })
+ @TestDataHolder(
+ successes = {
+ @TestData(submittedValue = "18-10-2010")
+ // ,@TestData(submittedValue = "17-10-2010")
+ },
+ failures = {
+ // @TestData(submittedValue = "10/17/2010")
+ }
+ )
+
public void testPattern() throws Exception {
setClientFunction("org.rf.DateTimeConverter");
setObjectId(DateTimeConverter.CONVERTER_ID);
Modified:
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/LengthValidatorTest.java
===================================================================
---
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/LengthValidatorTest.java 2010-11-02
06:22:38 UTC (rev 19883)
+++
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/LengthValidatorTest.java 2010-11-02
09:53:35 UTC (rev 19884)
@@ -39,7 +39,15 @@
}
@Test
- @TestDataHolder(successes = { @TestData(submittedValue = "dddd") },
failures = { @TestData(submittedValue = "1234567890A") })
+ @TestDataHolder(
+ successes = {
+ @TestData(submittedValue = "1234")
+ },
+ failures = {
+ @TestData(submittedValue = "1234567890A")
+ }
+ )
+
public void testSuccess() throws Exception {
setClientFunction("RichFaces.csv.getValidator('length')");
setObjectId(LengthValidator.VALIDATOR_ID);
@@ -48,4 +56,44 @@
setAttribute("maximum", 10);
setAttribute("minimum", 0);
}
+
+ @Test
+ @TestDataHolder(
+ successes = {
+ @TestData(submittedValue = "123"),
+ @TestData(submittedValue = "1234")
+ },
+ failures = {
+ @TestData(submittedValue = "12"),
+ @TestData(submittedValue = "")
+ }
+ )
+
+ public void minTestSuccess() throws Exception {
+ setClientFunction("RichFaces.csv.getValidator('length')");
+ setObjectId(LengthValidator.VALIDATOR_ID);
+ Enum<?>[] messages = { FacesMessages.LENGTH_VALIDATOR_MAXIMUM,
FacesMessages.LENGTH_VALIDATOR_MINIMUM };
+ setErrorMessageEnums(messages);
+ setAttribute("minimum", 3);
+ }
+
+ @Test
+ @TestDataHolder(
+ successes = {
+ @TestData(submittedValue = ""),
+ @TestData(submittedValue = "12"),
+ @TestData(submittedValue = "123")
+ },
+ failures = {
+ @TestData(submittedValue = "1234")
+ }
+ )
+
+ public void maxTestSuccess() throws Exception {
+ setClientFunction("RichFaces.csv.getValidator('length')");
+ setObjectId(LengthValidator.VALIDATOR_ID);
+ Enum<?>[] messages = { FacesMessages.LENGTH_VALIDATOR_MAXIMUM,
FacesMessages.LENGTH_VALIDATOR_MINIMUM };
+ setErrorMessageEnums(messages);
+ setAttribute("maximum", 3);
+ }
}
Modified:
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/NumberConverterTest.java
===================================================================
---
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/NumberConverterTest.java 2010-11-02
06:22:38 UTC (rev 19883)
+++
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/NumberConverterTest.java 2010-11-02
09:53:35 UTC (rev 19884)
@@ -39,7 +39,15 @@
}
@Test
- @TestDataHolder(successes = { @TestData(submittedValue = "111") }, failures
= { @TestData(submittedValue = "aaa") })
+ @TestDataHolder(
+ successes = {
+ @TestData(submittedValue = "111")
+ },
+ failures = {
+ @TestData(submittedValue = "aaa")
+ }
+ )
+
public void testSuccess() throws Exception {
setClientFunction("RichFaces.csv.getConverter('number')");
setObjectId(NumberConverter.CONVERTER_ID);
Modified:
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/ShortConverterTest.java
===================================================================
---
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/ShortConverterTest.java 2010-11-02
06:22:38 UTC (rev 19883)
+++
trunk/ui/validator/ui/src/test/java/org/richfaces/convert/ShortConverterTest.java 2010-11-02
09:53:35 UTC (rev 19884)
@@ -39,10 +39,23 @@
}
@Test
- @TestDataHolder(successes = { @TestData(submittedValue = "-32768"),
@TestData(submittedValue = "0"),
- @TestData(submittedValue = "32767") }, failures = {
@TestData(submittedValue = "-32769"),
- @TestData(submittedValue = "32768"), @TestData(submittedValue =
"1.0"), @TestData(submittedValue = "1.2"),
- @TestData(submittedValue = "1a"), @TestData(submittedValue =
"aaa"), @TestData(submittedValue = "- 10") })
+ @TestDataHolder(
+ successes = {
+ @TestData(submittedValue = "-32768"),
+ @TestData(submittedValue = "0"),
+ @TestData(submittedValue = "32767")
+ },
+ failures = {
+ @TestData(submittedValue = "-32769"),
+ @TestData(submittedValue = "32768"),
+ @TestData(submittedValue = "1.0"),
+ @TestData(submittedValue = "1.2"),
+ @TestData(submittedValue = "1a"),
+ @TestData(submittedValue = "aaa"),
+ @TestData(submittedValue = "- 10")
+ }
+ )
+
public void testSuccess() throws Exception {
setClientFunction("RichFaces.csv.getConverter('short')");
setObjectId(ShortConverter.CONVERTER_ID);