Changeset 1167
- Timestamp:
- Nov 18, 2010, 12:13:07 PM (12 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy
r1153 r1167 94 94 fields.each { key, value -> 95 95 // check if the value is of proper type 96 if (value && value.class != String) { 97 // it's of some other type 98 try { 99 // try to cast it to the proper type 100 fields[key] = (value as String) 101 } catch (Exception e) { 102 // could not typecast properly, value is of improper type 103 // add error message 96 if (value) { 97 def strValue = ""; 98 if( value.class != String) { 99 // it's of some other type 100 try { 101 // try to cast it to the proper type 102 strValue = (value as String) 103 fields[key] = strValue 104 } catch (Exception e) { 105 // could not typecast properly, value is of improper type 106 // add error message 107 error = true 108 errors.rejectValue( 109 'templateStringFields', 110 'templateEntity.typeMismatch.string', 111 [key, value.class] as Object[], 112 'Property {0} must be of type String and is currently of type {1}' 113 ) 114 } 115 } else { 116 strValue = value; 117 } 118 119 // Check whether the string doesn't exceed 255 characters 120 if( strValue.size() > 255 ) { 104 121 error = true 105 122 errors.rejectValue( 106 123 'templateStringFields', 107 'templateEntity.t ypeMismatch.string',108 [key , value.class] as Object[],109 'Property {0} m ust be of type String and is currently of type {1}'124 'templateEntity.tooLong.string', 125 [key] as Object[], 126 'Property {0} may contain at most 255 characters.' 110 127 ) 111 128 } -
trunk/grails-app/i18n/messages.properties
r416 r1167 58 58 templateEntity.typeMismatch.integer=Property {0} must be of type Integer and is currently of type {1} 59 59 templateEntity.typeMismatch.string=Property {0} must be of type String and is currently of type {1} 60 templateEntity.tooLong.string=Property {0} may contain at most 255 characters. 60 61 templateEntity.typeMismatch.templateFieldListItem=Property {0} must be of type TemplateFieldListItem and is currently of type {1} 61 62 templateEntity.typeMismatch.float=Property {0} must be of type Float and is currently of type {1}
Note: See TracChangeset
for help on using the changeset viewer.