From: Walter M. <wal...@us...> - 2007-09-09 11:02:57
|
User: walterim Date: 07/09/09 04:02:58 Modified: andromda-jsf2/src/main/resources/templates/jsf2/converters EnumerationConverter.java.vsl Log: Support to other enumeration types than String Revision Changes Path 1.2 +4 -2 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/converters/EnumerationConverter.java.vsl Index: EnumerationConverter.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/converters/EnumerationConverter.java.vsl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -w -r1.1 -r1.2 --- EnumerationConverter.java.vsl 5 Dec 2006 19:39:15 -0000 1.1 +++ EnumerationConverter.java.vsl 9 Sep 2007 11:02:58 -0000 1.2 @@ -30,7 +30,9 @@ java.lang.String value) throws javax.faces.convert.ConverterException { -#if ($enumeration.literalType.primitive) +#if(${enumeration.literalType.fullyQualifiedName} == "java.lang.String") + return value != null && value.trim().length() > 0 ? ${enumeration.fullyQualifiedName}.${enumeration.fromOperationName}(value) : null; +#elseif ($enumeration.literalType.primitive) try { #set ($parseSuffix = $stringUtils.capitalize($enumeration.literalType.name)) ${enumeration.literalType.fullyQualifiedName} v = ${enumeration.literalType.wrapperName}.parse${parseSuffix}(value); @@ -39,7 +41,7 @@ throw new javax.faces.convert.ConverterException(ex); } #else - return value != null && value.trim().length() > 0 ? ${enumeration.fullyQualifiedName}.${enumeration.fromOperationName}(value) : null; + return value != null && value.trim().length() > 0 ? ${enumeration.fullyQualifiedName}.${enumeration.fromOperationName}(new ${enumeration.literalType.fullyQualifiedName}(value)) : null; #end } } |
From: Walter M. <wal...@us...> - 2008-01-25 18:23:15
|
User: walterim Date: 08/01/25 10:23:16 Modified: andromda-jsf2/src/main/resources/templates/jsf2/converters EnumerationConverter.java.vsl Log: Corrected bug when using enumeration of type 'char' Revision Changes Path 1.3 +5 -1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/converters/EnumerationConverter.java.vsl Index: EnumerationConverter.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/converters/EnumerationConverter.java.vsl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -w -r1.2 -r1.3 --- EnumerationConverter.java.vsl 9 Sep 2007 11:02:58 -0000 1.2 +++ EnumerationConverter.java.vsl 25 Jan 2008 18:23:16 -0000 1.3 @@ -34,8 +34,12 @@ return value != null && value.trim().length() > 0 ? ${enumeration.fullyQualifiedName}.${enumeration.fromOperationName}(value) : null; #elseif ($enumeration.literalType.primitive) try { +#if(${enumeration.literalType.fullyQualifiedName} == "char") + char v = value.charAt(0); +#else #set ($parseSuffix = $stringUtils.capitalize($enumeration.literalType.name)) ${enumeration.literalType.fullyQualifiedName} v = ${enumeration.literalType.wrapperName}.parse${parseSuffix}(value); +#end return ${enumeration.fullyQualifiedName}.${enumeration.fromOperationName}(v); } catch (Exception ex) { throw new javax.faces.convert.ConverterException(ex); |
From: Walter M. <wal...@us...> - 2008-02-25 14:21:19
|
User: walterim Date: 08/02/25 06:21:24 Modified: andromda-jsf2/src/main/resources/templates/jsf2/converters EnumerationConverter.java.vsl Log: Using resource strings instead of .toString() Revision Changes Path 1.4 +1 -1 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/converters/EnumerationConverter.java.vsl Index: EnumerationConverter.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/converters/EnumerationConverter.java.vsl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -w -r1.3 -r1.4 --- EnumerationConverter.java.vsl 25 Jan 2008 18:23:16 -0000 1.3 +++ EnumerationConverter.java.vsl 25 Feb 2008 14:21:24 -0000 1.4 @@ -18,7 +18,7 @@ java.lang.Object value) throws javax.faces.convert.ConverterException { - return value != null ? value.toString() : null; + return value != null ? ${managedBeansPackage}.Messages.get("${enumeration.messageKey}."+value.toString(),null) : null; } /** |
From: Walter M. <wal...@us...> - 2008-08-05 17:30:49
|
User: walterim Date: 08/08/05 10:31:00 Modified: andromda-jsf2/src/main/resources/templates/jsf2/converters EnumerationConverter.java.vsl Log: Stopped using properties to get the string value in the conversion. t was a wrong choice. Revision Changes Path 1.5 +14 -7 cartridges/andromda-jsf2/src/main/resources/templates/jsf2/converters/EnumerationConverter.java.vsl Index: EnumerationConverter.java.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-jsf2/src/main/resources/templates/jsf2/converters/EnumerationConverter.java.vsl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- EnumerationConverter.java.vsl 25 Feb 2008 14:21:24 -0000 1.4 +++ EnumerationConverter.java.vsl 5 Aug 2008 17:30:59 -0000 1.5 @@ -18,7 +18,7 @@ java.lang.Object value) throws javax.faces.convert.ConverterException { - return value != null ? ${managedBeansPackage}.Messages.get("${enumeration.messageKey}."+value.toString(),null) : null; + return (value == null || value.toString().trim().length() == 0) ? "": ((${enumeration.fullyQualifiedName})value).toString(); } /** @@ -33,6 +33,12 @@ #if(${enumeration.literalType.fullyQualifiedName} == "java.lang.String") return value != null && value.trim().length() > 0 ? ${enumeration.fullyQualifiedName}.${enumeration.fromOperationName}(value) : null; #elseif ($enumeration.literalType.primitive) + if(value == null || value.trim().length() == 0) + { + return null; + } + else + { try { #if(${enumeration.literalType.fullyQualifiedName} == "char") char v = value.charAt(0); @@ -44,6 +50,7 @@ } catch (Exception ex) { throw new javax.faces.convert.ConverterException(ex); } + } #else return value != null && value.trim().length() > 0 ? ${enumeration.fullyQualifiedName}.${enumeration.fromOperationName}(new ${enumeration.literalType.fullyQualifiedName}(value)) : null; #end |