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 2008/05/29 08:52:18 UTC

svn commit: r661228 - in /myfaces/tomahawk/trunk/sandbox/core: ./ src/main/java/org/apache/myfaces/custom/comparetovalidator/ src/main/java/org/apache/myfaces/custom/convertDateTime/ src/main/java/org/apache/myfaces/custom/convertNumber/ src/main/java/...

Author: lu4242
Date: Wed May 28 23:52:17 2008
New Revision: 661228

URL: http://svn.apache.org/viewvc?rev=661228&view=rev
Log:
TOMAHAWK-1262 Converter and Validator Tag generation

Added:
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagConverterClass11.vm
    myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagValidatorClass11.vm
Removed:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/ValidateCompareToTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertDateTime/ConvertDateTimeTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertNumber/TypedNumberConverterTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertStringUtils/StringUtilsConverterTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertboolean/ConvertBooleanTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/ValidateCSVTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/isbnvalidator/ValidateISBNTag.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/ValidateUrlTag.java
Modified:
    myfaces/tomahawk/trunk/sandbox/core/pom.xml
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertStringUtils/StringUtilsConverter.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertboolean/BooleanConverter.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/CSVValidator.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/isbnvalidator/ISBNValidator.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/UrlValidator.java

Modified: myfaces/tomahawk/trunk/sandbox/core/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/pom.xml?rev=661228&r1=661227&r2=661228&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/pom.xml (original)
+++ myfaces/tomahawk/trunk/sandbox/core/pom.xml Wed May 28 23:52:17 2008
@@ -229,6 +229,13 @@
 			      </goals>
 			    </execution>
 				<execution>
+				  <id>make_validator_tags_tomahawk</id>
+				  <goals>
+				      <goal>make-validator-tags</goal>
+				      <goal>make-converter-tags</goal>
+				  </goals>
+				</execution>			    
+				<execution>
 				  <id>makesandboxtld</id>
 				  <configuration>
 				      <xmlFile>META-INF/myfaces_sandbox.tld</xmlFile>

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java?rev=661228&r1=661227&r2=661228&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/comparetovalidator/CompareToValidator.java Wed May 28 23:52:17 2008
@@ -124,8 +124,10 @@
  * @JSFValidator
  *   name = "s:validateCompareTo"
  *   tagClass = "org.apache.myfaces.custom.comparetovalidator.ValidateCompareToTag"
+ *   tagSuperclass = "org.apache.myfaces.validator.ValidatorBaseTag"
+ *   serialuidtag = "-8879289182242196266L"
  *   
- * @JSFJspProperty name = "message" returnType = "java.lang.String" longDesc = "alternate validation error message format string"
+ * @JSFJspProperty name = "message" inheritedTag="true" returnType = "java.lang.String" longDesc = "alternate validation error message format string"
  * 
  * @author Mike Kienenberger (latest modification by $Author$)
  * @version $Revision$ $Date$

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertStringUtils/StringUtilsConverter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertStringUtils/StringUtilsConverter.java?rev=661228&r1=661227&r2=661228&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertStringUtils/StringUtilsConverter.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertStringUtils/StringUtilsConverter.java Wed May 28 23:52:17 2008
@@ -45,6 +45,7 @@
  * @JSFConverter
  *   name = "s:convertStringUtils"
  *   tagClass = "org.apache.myfaces.custom.convertStringUtils.StringUtilsConverterTag" 
+ *   serialuidtag = "-8532160892717473339L"
  *   
  * @author Julian Ray
  */

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertboolean/BooleanConverter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertboolean/BooleanConverter.java?rev=661228&r1=661227&r2=661228&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertboolean/BooleanConverter.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/convertboolean/BooleanConverter.java Wed May 28 23:52:17 2008
@@ -41,7 +41,8 @@
  *
  * @JSFConverter
  *   name = "s:convertBoolean"
- *   tagClass = "org.apache.myfaces.custom.convertboolean.ConvertBooleanTag" 
+ *   tagClass = "org.apache.myfaces.custom.convertboolean.ConvertBooleanTag"
+ *   serialuidtag = "-6004262065580818687L" 
  *   
  * @author Ken Weiner
  */

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/CSVValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/CSVValidator.java?rev=661228&r1=661227&r2=661228&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/CSVValidator.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/csvvalidator/CSVValidator.java Wed May 28 23:52:17 2008
@@ -32,8 +32,10 @@
  * @JSFValidator
  *   name = "s:validateCSV"
  *   tagClass = "org.apache.myfaces.custom.csvvalidator.ValidateCSVTag"
+ *   tagSuperclass = "org.apache.myfaces.validator.ValidatorBaseTag"
+ *   serialuidtag = "-8874279182242196266L"
  *
- * @JSFJspProperty name = "message" returnType = "java.lang.String" longDesc = "alternate validation error message format string"
+ * @JSFJspProperty name = "message" inheritedTag="true" returnType = "java.lang.String" longDesc = "alternate validation error message format string"
  * @author Lance Frohman
  *
  * @version $Revision: $ $Date: $

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/isbnvalidator/ISBNValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/isbnvalidator/ISBNValidator.java?rev=661228&r1=661227&r2=661228&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/isbnvalidator/ISBNValidator.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/isbnvalidator/ISBNValidator.java Wed May 28 23:52:17 2008
@@ -32,8 +32,10 @@
  * @JSFValidator
  *   name = "s:validateISBN"
  *   tagClass = "org.apache.myfaces.custom.isbnvalidator.ValidateISBNTag"
+ *   tagSuperclass = "org.apache.myfaces.validator.ValidatorBaseTag"
+ *   serialuidtag = "5230653358032218656L"
  *   
- * @JSFJspProperty name = "message" returnType = "java.lang.String" longDesc = "alternate validation error message format string"
+ * @JSFJspProperty name = "message" inheritedTag="true" returnType = "java.lang.String" longDesc = "alternate validation error message format string"
  * @author <a href="mailto:matzew@apache.org">Matthias We&szlig;endorf</a> (latest modification by $Author$)
  * @version $Revision$ $Date$
  */

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/UrlValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/UrlValidator.java?rev=661228&r1=661227&r2=661228&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/UrlValidator.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/UrlValidator.java Wed May 28 23:52:17 2008
@@ -33,8 +33,10 @@
  * @JSFValidator
  *   name = "s:validateUrl"
  *   tagClass = "org.apache.myfaces.custom.urlvalidator.ValidateUrlTag"
+ *   tagSuperclass = "org.apache.myfaces.validator.ValidatorBaseTag"
+ *   serialuidtag = "6041422002721046221L"
  *
- * @JSFJspProperty name = "message" returnType = "java.lang.String" longDesc = "alternate validation error message format string"
+ * @JSFJspProperty name = "message" inheritedTag="true" returnType = "java.lang.String" longDesc = "alternate validation error message format string"
  * @author Fabian Frederick
  *
  * @version $Revision: $ $Date: $

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagConverterClass11.vm
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagConverterClass11.vm?rev=661228&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagConverterClass11.vm (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagConverterClass11.vm Wed May 28 23:52:17 2008
@@ -0,0 +1,159 @@
+// WARNING: This file was automatically generated. Do not edit it directly,
+//          or you will lose your changes.
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package $utils.getPackageFromFullClass($converter.tagClass);
+
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.el.ValueBinding;
+import javax.faces.webapp.UIComponentTag;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+$utils.importTagClasses($converter)
+
+public class $utils.getClassFromFullClass($converter.tagClass)
+#if (${converter.tagSuperclass})
+    extends ${converter.tagSuperclass}
+#else
+    extends javax.faces.webapp.ConverterTag
+#end
+{
+#if ($converter.serialuidtag)
+    private static final long serialVersionUID = ${converter.serialuidtag}; 
+#end  
+
+    public $utils.getClassFromFullClass($converter.tagClass)()
+    {
+        setConverterId("$converter.converterId");
+    }
+#set ($propertyList = ${converter.propertyTagList})
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $utils.getJspPropertyType11($property))
+ 
+    private $type $field;
+    
+#set ($var = $utils.getVariableFromName($property.name))
+    public void $utils.getPrefixedPropertyName("set", $property.jspName)($type $var)
+    {
+        $field = $var;
+    }
+#end
+
+    public void setPageContext(PageContext context) {
+        super.setPageContext(context);
+        setConverterId("$converter.converterId");
+    }
+
+    protected Converter createConverter() throws JspException {
+    
+        FacesContext facesContext = FacesContext.getCurrentInstance();            
+        $converter.className converter = ($converter.className)super.createConverter();
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $utils.getJspPropertyType11($property))
+#set ($className = $utils.getPrimitiveType($property.className))
+        if ($field != null)
+        {
+            if (UIComponentTag.isValueReference($field))
+            {
+                ValueBinding vb = facesContext.getApplication().createValueBinding($field);
+#if ($utils.isPrimitiveClass($property.className))                
+                converter.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf(vb.getValue(facesContext).toString()).${property.className}Value());
+#elseif ($utils.isPrimitiveClass($className))
+                converter.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf(vb.getValue(facesContext).toString()));
+#elseif ($utils.getClassFromFullClass($property.className) == "String")
+                converter.${utils.getPrefixedPropertyName("set",$property.name)}(new String(vb.getValue(facesContext).toString()));
+#elseif ($utils.getClassFromFullClass($property.className) == "Object")
+                converter.${utils.getPrefixedPropertyName("set",$property.name)}(vb.getValue(facesContext));
+#elseif ($utils.getClassFromFullClass($property.className) == "Locale")
+                Object ${field}Value = vb.getValue(facesContext);
+                if(${field}Value instanceof java.util.Locale)
+                {
+                    converter.${utils.getPrefixedPropertyName("set",$property.name)}(
+                        (java.util.Locale) ${field}Value);
+                }
+                else
+                {
+                    converter.${utils.getPrefixedPropertyName("set",$property.name)}(
+                        org.apache.myfaces.shared_tomahawk.util.LocaleUtils.converterTagLocaleFromString($field));
+                
+                }
+#elseif ($utils.getClassFromFullClass($property.className) == "TimeZone")
+                Object ${field}Value = vb.getValue(facesContext);
+                if(${field}Value instanceof java.util.TimeZone)
+                {
+                    converter.${utils.getPrefixedPropertyName("set",$property.name)}(
+                        (java.util.TimeZone) ${field}Value);
+                }
+                else
+                {
+                    converter.${utils.getPrefixedPropertyName("set",$property.name)}(
+                        java.util.TimeZone.getTimeZone($field));
+                }
+#else
+                converter.${utils.getPrefixedPropertyName("set",$property.name)}(($property.className) vb.getValue(facesContext));
+#end
+            }
+            else
+            {
+#if ($utils.isPrimitiveClass($property.className))
+                converter.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf($field).${property.className}Value());
+#elseif ($utils.isPrimitiveClass($className))
+                converter.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf($field));
+#elseif ($utils.getClassFromFullClass($property.className) == "Locale")
+                converter.${utils.getPrefixedPropertyName("set",$property.name)}(
+                    org.apache.myfaces.shared_tomahawk.util.LocaleUtils.converterTagLocaleFromString($field));
+#elseif ($utils.getClassFromFullClass($property.className) == "TimeZone")
+                converter.${utils.getPrefixedPropertyName("set",$property.name)}(
+                    java.util.TimeZone.getTimeZone($field));                
+#elseif ($utils.getClassFromFullClass($property.className) == "Class")
+                try
+                {
+                    converter.${utils.getPrefixedPropertyName("set",$property.name)}(
+                    org.apache.myfaces.shared_tomahawk.util.ClassUtils.classForName($field));
+                }
+                catch (ClassNotFoundException e)
+                {
+                    throw new JspException(e);
+                }
+#else
+                converter.${utils.getPrefixedPropertyName("set",$property.name)}($field);
+#end
+            }
+        }
+#end
+        return converter;
+    }
+
+    public void release()
+    {
+        super.release();
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#if($utils.getJspPropertyType11($property) == "boolean")
+#set ($empty = "false")
+#else
+#set ($empty = "null")
+#end
+        $field = $empty;
+#end
+    }
+}
\ No newline at end of file

Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagValidatorClass11.vm
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagValidatorClass11.vm?rev=661228&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagValidatorClass11.vm (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/META-INF/tagValidatorClass11.vm Wed May 28 23:52:17 2008
@@ -0,0 +1,110 @@
+// WARNING: This file was automatically generated. Do not edit it directly,
+//          or you will lose your changes.
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ * 
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package $utils.getPackageFromFullClass($validator.tagClass);
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.validator.Validator;
+import javax.faces.webapp.UIComponentTag;
+import javax.servlet.jsp.JspException;
+$utils.importTagClasses($validator)
+
+public class $utils.getClassFromFullClass($validator.tagClass)
+#if (${validator.tagSuperclass})
+    extends ${validator.tagSuperclass}
+#else
+    extends javax.faces.webapp.ValidatorTag;
+#end
+{
+#if ($validator.serialuidtag)
+    private static final long serialVersionUID = ${validator.serialuidtag}; 
+#end  
+
+    public $utils.getClassFromFullClass($validator.tagClass)()
+    {    
+    }    
+#set ($propertyList = ${validator.propertyTagList})
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $utils.getJspPropertyType11($property))
+ 
+    private $type $field;
+    
+#set ($var = $utils.getVariableFromName($property.name))
+    public void $utils.getPrefixedPropertyName("set", $property.jspName)($type $var)
+    {
+        $field = $var;
+    }
+#end
+
+    protected Validator createValidator() throws JspException {
+    
+        FacesContext facesContext = FacesContext.getCurrentInstance();
+        setValidatorId("$validator.validatorId");    
+        $validator.className validator = ($validator.className)super.createValidator();
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#set ($type = $utils.getJspPropertyType11($property))
+#set ($className = $utils.getPrimitiveType($property.className))
+        if ($field != null)
+        {
+            if (UIComponentTag.isValueReference($field))
+            {
+                ValueBinding vb = facesContext.getApplication().createValueBinding($field);
+#if ($utils.isPrimitiveClass($property.className))                
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf(vb.getValue(facesContext).toString()).${property.className}Value());
+#elseif ($utils.isPrimitiveClass($className))
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf(vb.getValue(facesContext).toString()));
+#elseif ($utils.getClassFromFullClass($property.className) == "String")
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}(new String(vb.getValue(facesContext).toString()));
+#else
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}(vb.getValue(facesContext));
+#end
+            }
+            else
+            {
+#if ($utils.isPrimitiveClass($property.className))
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf($field).${property.className}Value());
+#elseif ($utils.isPrimitiveClass($className))
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}(${utils.getBoxedClass($className)}.valueOf($field));
+#else
+                validator.${utils.getPrefixedPropertyName("set",$property.name)}($field);
+#end
+            }
+        }
+#end
+        return validator;
+    }
+
+    public void release()
+    {
+        super.release();
+#foreach( $property in $propertyList )
+#set ($field = $property.fieldName)
+#if($utils.getJspPropertyType11($property) == "boolean")
+#set ($empty = "false")
+#else
+#set ($empty = "null")
+#end
+        $field = $empty;
+#end
+    }
+}