You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/11/10 02:06:15 UTC
svn commit: r1033311 - in /myfaces/commons/trunk:
myfaces-commons-converters/src/main/resources/META-INF/converterClass12.vm
myfaces-commons-validators/src/main/resources/META-INF/validatorClass12.vm
Author: lu4242
Date: Wed Nov 10 01:06:14 2010
New Revision: 1033311
URL: http://svn.apache.org/viewvc?rev=1033311&view=rev
Log:
use velocity macros for templates
Modified:
myfaces/commons/trunk/myfaces-commons-converters/src/main/resources/META-INF/converterClass12.vm
myfaces/commons/trunk/myfaces-commons-validators/src/main/resources/META-INF/validatorClass12.vm
Modified: myfaces/commons/trunk/myfaces-commons-converters/src/main/resources/META-INF/converterClass12.vm
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-converters/src/main/resources/META-INF/converterClass12.vm?rev=1033311&r1=1033310&r2=1033311&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-converters/src/main/resources/META-INF/converterClass12.vm (original)
+++ myfaces/commons/trunk/myfaces-commons-converters/src/main/resources/META-INF/converterClass12.vm Wed Nov 10 01:06:14 2010
@@ -58,35 +58,46 @@ public class ${utils.getClassFromFullCla
public ${utils.getClassFromFullClass($converter.className)}()
{
}
-
-#set ($propertyList = ${converter.propertyConverterList})
-#foreach( $property in $propertyList )
-#set ($field = $property.fieldName)
-#set ($type = $utils.getClassFromFullClass($property.className))
-#if($utils.getDefaultValueField($property))
-#set ($defaultValue = $utils.getDefaultValueField($property))
-#else
-#set ($defaultValue = false)
+## ----------------------------- PROPERTY MACROS -----------------------------
+##
+## -------------------------------
+## writePropertySetDeclaration
+## -------------------------------
+##
+#macro (writePropertySetDeclaration $property $type $field $defaultValue )
+#if($utils.isPrimitiveClass($type) && !$property.isTagExcluded() )
+ private boolean ${field}Set;
+
#end
- // Property: $property.name
-#if ($property.isLiteralOnly() || $property.isTagExcluded() )
+#end
+##
+## -------------------------------
+## writePropertyDeclaration
+## -------------------------------
+##
+#macro( writePropertyDeclaration $property $type $field $defaultValue )
+#if ($property.isLiteralOnly() || $property.isTagExcluded() || !($converter.isEvaluateELOnExecution()))
private $type $field #if($defaultValue) = $defaultValue;#{else};#{end}
-
#else
private $type $field;
#end
-#if($utils.isPrimitiveClass($type) && !$property.isTagExcluded() )
- private boolean ${field}Set;
-
-#if ($property.isSetMethod())
+#writePropertySetDeclaration ($property $type $field $defaultValue)
+#end
+##
+## -------------------------------
+## writeLocalPropertyGetter
+## -------------------------------
+##
+#macro (writeLocalPropertyGetter $property $type $field $defaultValue )
+#if($utils.isPrimitiveClass($type) && !$property.isTagExcluded() && $property.isSetMethod())
$property.setMethodScope boolean $utils.getPrefixedPropertyName("isSet", $property.name)()
{
return ${field}Set;
}
-#end
+
#end
#if($property.isLocalMethod())
#if("boolean" == $type)
@@ -98,8 +109,15 @@ public class ${utils.getClassFromFullCla
{
return $field;
}
-
+
#end
+#end
+##
+## -------------------------------
+## writePropertyGetter
+## -------------------------------
+##
+#macro (writePropertyGetter $property $type $field $defaultValue )
public $type $utils.getMethodReaderFromProperty($property.name, $type)()
{
#if ($property.isTagExcluded() || $property.isLiteralOnly() || !($converter.isEvaluateELOnExecution()))
@@ -141,6 +159,13 @@ public class ${utils.getClassFromFullCla
#end
}
+#end
+##
+## -------------------------------
+## writePropertySetter
+## -------------------------------
+##
+#macro (writePropertySetter $property $type $field $defaultValue )
public void $utils.getPrefixedPropertyName("set", $property.name)($type $utils.getVariableFromName($property.name))
{
this.$field = $utils.getVariableFromName($property.name);
@@ -148,7 +173,29 @@ public class ${utils.getClassFromFullCla
this.${field}Set = true;
#end
}
+
+#end
+##
+## ----------------------------- END PROPERTY MACROS -------------------------
+##
+## ----------------------------- START PROPERTY RENDERING --------------------
+#set ($propertyList = ${converter.propertyConverterList})
+
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $utils.getClassFromFullClass($property.className))
+#if($utils.getDefaultValueField($property))
+#set ($defaultValue = $utils.getDefaultValueField($property))
+#else
+#set ($defaultValue = false)
+#end
+ // Property: $property.name
+#writePropertyDeclaration($property $type $field $defaultValue)
+#writeLocalPropertyGetter ($property $type $field $defaultValue)
+#writePropertyGetter ($property $type $field $defaultValue)
+#writePropertySetter ($property $type $field $defaultValue)
#end
+## ----------------------------- END PROPERTY RENDERING ---------------------
public Object saveState(FacesContext facesContext)
{
@@ -165,7 +212,7 @@ public class ${utils.getClassFromFullCla
#set ($field = $property.fieldName)
#set ($type = $property.className)
#set ($arrayIndex = $arrayIndex + 1)
-#if ($property.jspName == "converter" && $property.isMethodBinding() )
+#if ($property.jspName == "validator" && $property.isMethodBinding() )
values[$arrayIndex] = saveAttachedState(facesContext,${field}List);
#elseif ( $property.isStateHolder() )## || $utils.isConverter($type)
values[$arrayIndex] = saveAttachedState(facesContext,$field);
@@ -192,8 +239,8 @@ public class ${utils.getClassFromFullCla
#set ($type = $property.className)
#set ($arrayIndex = $arrayIndex + 1)
#if ( $property.isStateHolder() )
-#if ($property.jspName == "converter" && $property.isMethodBinding() )
- ${field}List = (List<Converter>) restoreAttachedState(facesContext,values[$arrayIndex]);
+#if ($property.jspName == "validator" && $property.isMethodBinding() )
+ ${field}List = (List<Validator>) restoreAttachedState(facesContext,values[$arrayIndex]);
#elseif ($utils.isList($type))
$field = (List) restoreAttachedState(facesContext,values[$arrayIndex]);
#else
Modified: myfaces/commons/trunk/myfaces-commons-validators/src/main/resources/META-INF/validatorClass12.vm
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-validators/src/main/resources/META-INF/validatorClass12.vm?rev=1033311&r1=1033310&r2=1033311&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-validators/src/main/resources/META-INF/validatorClass12.vm (original)
+++ myfaces/commons/trunk/myfaces-commons-validators/src/main/resources/META-INF/validatorClass12.vm Wed Nov 10 01:06:14 2010
@@ -58,35 +58,46 @@ public class ${utils.getClassFromFullCla
public ${utils.getClassFromFullClass($validator.className)}()
{
}
-
-#set ($propertyList = ${validator.propertyValidatorList})
-#foreach( $property in $propertyList )
-#set ($field = $property.fieldName)
-#set ($type = $utils.getClassFromFullClass($property.className))
-#if($utils.getDefaultValueField($property))
-#set ($defaultValue = $utils.getDefaultValueField($property))
-#else
-#set ($defaultValue = false)
+## ----------------------------- PROPERTY MACROS -----------------------------
+##
+## -------------------------------
+## writePropertySetDeclaration
+## -------------------------------
+##
+#macro (writePropertySetDeclaration $property $type $field $defaultValue )
+#if($utils.isPrimitiveClass($type) && !$property.isTagExcluded() )
+ private boolean ${field}Set;
+
#end
- // Property: $property.name
-#if ($property.isLiteralOnly() || $property.isTagExcluded() )
+#end
+##
+## -------------------------------
+## writePropertyDeclaration
+## -------------------------------
+##
+#macro( writePropertyDeclaration $property $type $field $defaultValue )
+#if ($property.isLiteralOnly() || $property.isTagExcluded() || !($validator.isEvaluateELOnExecution()))
private $type $field #if($defaultValue) = $defaultValue;#{else};#{end}
-
#else
private $type $field;
#end
-#if($utils.isPrimitiveClass($type) && !$property.isTagExcluded() )
- private boolean ${field}Set;
-
-#if ($property.isSetMethod())
+#writePropertySetDeclaration ($property $type $field $defaultValue)
+#end
+##
+## -------------------------------
+## writeLocalPropertyGetter
+## -------------------------------
+##
+#macro (writeLocalPropertyGetter $property $type $field $defaultValue )
+#if($utils.isPrimitiveClass($type) && !$property.isTagExcluded() && $property.isSetMethod())
$property.setMethodScope boolean $utils.getPrefixedPropertyName("isSet", $property.name)()
{
return ${field}Set;
}
-#end
+
#end
#if($property.isLocalMethod())
#if("boolean" == $type)
@@ -98,8 +109,15 @@ public class ${utils.getClassFromFullCla
{
return $field;
}
-
+
#end
+#end
+##
+## -------------------------------
+## writePropertyGetter
+## -------------------------------
+##
+#macro (writePropertyGetter $property $type $field $defaultValue )
public $type $utils.getMethodReaderFromProperty($property.name, $type)()
{
#if ($property.isTagExcluded() || $property.isLiteralOnly() || !($validator.isEvaluateELOnExecution()))
@@ -141,6 +159,13 @@ public class ${utils.getClassFromFullCla
#end
}
+#end
+##
+## -------------------------------
+## writePropertySetter
+## -------------------------------
+##
+#macro (writePropertySetter $property $type $field $defaultValue )
public void $utils.getPrefixedPropertyName("set", $property.name)($type $utils.getVariableFromName($property.name))
{
this.$field = $utils.getVariableFromName($property.name);
@@ -148,7 +173,29 @@ public class ${utils.getClassFromFullCla
this.${field}Set = true;
#end
}
+
+#end
+##
+## ----------------------------- END PROPERTY MACROS -------------------------
+##
+## ----------------------------- START PROPERTY RENDERING --------------------
+#set ($propertyList = ${validator.propertyValidatorList})
+
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $utils.getClassFromFullClass($property.className))
+#if($utils.getDefaultValueField($property))
+#set ($defaultValue = $utils.getDefaultValueField($property))
+#else
+#set ($defaultValue = false)
+#end
+ // Property: $property.name
+#writePropertyDeclaration($property $type $field $defaultValue)
+#writeLocalPropertyGetter ($property $type $field $defaultValue)
+#writePropertyGetter ($property $type $field $defaultValue)
+#writePropertySetter ($property $type $field $defaultValue)
#end
+## ----------------------------- END PROPERTY RENDERING ---------------------
public Object saveState(FacesContext facesContext)
{