Author: nbelaevski
Date: 2007-04-24 06:22:53 -0400 (Tue, 24 Apr 2007)
New Revision: 115
Added:
trunk/cdk/generator/src/main/resources/META-INF/templates/componentTag.vm
trunk/cdk/generator/src/main/resources/META-INF/templates/converter.vm
trunk/cdk/generator/src/main/resources/META-INF/templates/converterTag.vm
trunk/cdk/generator/src/main/resources/META-INF/templates/validator.vm
trunk/cdk/generator/src/main/resources/META-INF/templates/validatorTag.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/validator.vm
Log:
Missing templates added
Added: trunk/cdk/generator/src/main/resources/META-INF/templates/componentTag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/componentTag.vm
(rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/componentTag.vm 2007-04-24
10:22:53 UTC (rev 115)
@@ -0,0 +1,149 @@
+/**
+ * GENERATED FILE - DO NOT EDIT
+ *
+ */
+package ${tag.packageName};
+
+#foreach($import in $imports)
+import $import ;
+#end
+import javax.faces.component.UIComponent;
+import ${component.classname};
+
+public class $tag.simpleClassName extends $tag.superclass {
+
+// Fields
+#foreach( $prop in $component.properties )
+ #if( !$prop.existintag )
+ /*
+ * $prop.name
+ * ${prop.xmlEncodedDescription}
+ */
+ private String _$prop.name = null;
+
+ #end
+#end
+// Setters
+#foreach( $prop in $component.properties )
+ #if( !$prop.existintag )
+ /*
+ * $prop.name
+ * ${prop.xmlEncodedDescription}
+ */
+ /*
+ * $prop.description
+ * Setter for $prop.name
+ * @param $prop.name - new value
+ */
+ public void ${prop.setterName}( String __${prop.name} ){
+ this._${prop.name} = __${prop.name};
+ }
+
+ #end
+ #if( $prop.alias)
+ /*
+ * ${prop.xmlEncodedDescription}
+ * Setter for alias of $prop.name as $prop.alias
+ * @param $prop.name - new value
+ */
+ public void set${prop.upperFirstChar($prop.alias)}( String __${prop.alias} ){
+ this.${prop.setterName}(__${prop.alias});
+ }
+ #end
+#end
+// Release
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#release()
+ */
+ public void release()
+ {
+ // TODO Auto-generated method stub
+ super.release();
+#foreach( $prop in $component.properties )
+ #if( !$prop.existintag )
+ this._${prop.name} = null;
+ #end
+#end
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
+ */
+ protected void setProperties(UIComponent component)
+ {
+ // TODO Auto-generated method stub
+ super.setProperties(component);
+
+#foreach( $prop in $component.properties )
+ #if( !$prop.existintag )
+ #if(!$prop.el)
+ if(isValueReference(this._${prop.name})){
+ throw new IllegalArgumentException("Component ${component.name} with Id " +
component.getClientId(getFacesContext() +" not allowed EL expression for property
${prop.name}")
+ }
+ #end
+ #if($prop.name == "action")
+ setActionProperty(component, this._${prop.name});
+ #elseif($prop.name == "actionListener")
+ setActionListenerProperty(component, this._${prop.name});
+ #elseif($prop.name == "converter")
+ setConverterProperty(component, this._${prop.name});
+ #elseif($prop.name == "validator")
+ setValidatorProperty(component, this._${prop.name});
+ #elseif($prop.name == "valueChangeListener")
+ setValueChangedListenerProperty(component, this._${prop.name});
+ #elseif($prop.name == "value")
+ setValueProperty(component, this._${prop.name});
+ #elseif($prop.elOnly || $prop.isInstanceof("javax.faces.el.ValueBinding") )
+ setValueBinding(component, "${prop.name}",this._${prop.name});
+ #elseif(${prop.simpleType})
+ // Simple type - ${prop.simpleClassName}
+ set${prop.boxingClass}Property(component,
"${prop.name}",this._${prop.name});
+ #elseif($prop.classname == "java.lang.Boolean" || $prop.classname ==
"java.lang.Integer" || $prop.classname == "java.lang.Long")
+ set${prop.simpleClassName}Property(component,
"${prop.name}",this._${prop.name});
+ #elseif( $prop.classname == "java.lang.String")
+ setStringProperty(component, "${prop.name}",this._${prop.name});
+ #elseif( $prop.classname == "java.lang.Object")
+ // TODO - handle object
+ setStringProperty(component, "${prop.name}",this._${prop.name});
+ #elseif( $prop.isInstanceof("javax.faces.el.MethodBinding") )
+ if(null != this._${prop.name}){
+ if (isValueReference(this._${prop.name}))
+ {
+ MethodBinding mb =
getFacesContext().getApplication().createMethodBinding(this._${prop.name},
+ new
Class[]{${prop.methodargs}});
+ ((${component.simpleClassName})component).${prop.setterName}(mb);
+ }
+ else
+ {
+ getFacesContext().getExternalContext().log("Component " +
component.getClientId(getFacesContext()) + " has invalid ${prop.name} value: " +
this._${prop.name});
+ }
+ }
+ #else
+ // TODO - setup properties for other cases.
+ // name ${prop.name} with type $prop.classname
+ #end
+ #end
+#end
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType() {
+ // TODO Auto-generated method stub
+ return "${component.name}";
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.webapp.UIComponentTag#getRendererType()
+ */
+ public String getRendererType() {
+ #if($renderer)
+ return "${renderer.name}";
+ #else
+ return null;
+ #end
+ }
+
+}
Added: trunk/cdk/generator/src/main/resources/META-INF/templates/converter.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/converter.vm
(rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/converter.vm 2007-04-24
10:22:53 UTC (rev 115)
@@ -0,0 +1,186 @@
+package $package;
+
+#foreach($import in $imports)
+import $import ;
+#end
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import java.io.IOException;
+import javax.faces.FacesException;
+
+/**
+ * Converter-Id ${converter.id}
+ * ${converter.xmlEncodedDescription}
+ */
+public class $converter.simpleClassName extends $converter.superclass
+{
+
+ public static final String CONVERTER_ID = "${converter.id}";
+
+ /**
+ * Default no-args contstructor
+ */
+ public $converter.simpleClassName ()
+ {
+ }
+
+// Conveter properties fields
+#set( $fiedCounter = 1 )
+#foreach( $prop in $converter.properties )
+ #if( !$prop.exist )
+ /**
+ * $prop.name
+ * ${prop.xmlEncodedDescription}
+ */
+ #if($prop.simpleType)
+ private $prop.simpleClassName _$prop.name = ${prop.defaultvalue};
+ /**
+ * Flag indicated that $prop.name is set.
+ */
+ private boolean _${prop.name}Set = false;
+ #set( $fiedCounter = $fiedCounter+2)
+ #else
+ private $prop.simpleClassName _$prop.name = null; /* Default is
${prop.defaultvalue}*/
+ #set( $fiedCounter = $fiedCounter+1)
+ #end
+ #end
+#end
+
+// Getters and setters
+#foreach( $prop in $converter.properties )
+ #if( !$prop.exist )
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Setter for $prop.name
+ * @param $prop.name - new value
+ */
+ public void ${prop.setterName}( $prop.simpleClassName __$prop.name )
+ {
+ this._${prop.name} = __$prop.name;
+ #if($prop.simpleType)
+ this._${prop.name}Set = true;
+ #end
+ }
+
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Getter for $prop.name
+ * @return $prop.name value from local variable or value binding
+ */
+ public $prop.simpleClassName ${prop.getterName}()
+ {
+ ValueBinding vb = getValueBinding("${prop.name}");
+ #if($prop.simpleType)
+ if(this._${prop.name}Set)
+ {
+ return this._${prop.name};
+ }
+ if (vb != null)
+ {
+ ${prop.boxingClass} value = (${prop.boxingClass}) vb.getValue(getFacesContext());
+ if (null == value)
+ {
+ return this._${prop.name};
+ }
+ //return (value.${prop.classname}Value());
+ } else
+ {
+ return (this._${prop.name});
+ }
+ }
+ #else
+ if (null != this._${prop.name})
+ {
+ return this._${prop.name};
+ }
+ #if( !$prop.isInstanceof("javax.faces.el.MethodBinding") &&
!$prop.isInstanceof("javax.faces.el.ValueBinding"))
+ else if (null != vb)
+ {
+ return (${prop.simpleClassName})vb.getValue(getFacesContext());
+ }
+ #end
+ else
+ {
+ return ${prop.defaultvalue};
+ }
+ #end
+ #if($prop.raw)
+ /**
+ * ${prop.xmlEncodedDescription}
+ * Raw Setter for $prop.name
+ * @param $prop.name - new value
+ */
+ public void ${prop.setterName}Raw( $prop.simpleClassName __$prop.name )
+ {
+ this._${prop.name} = __$prop.name;
+ }
+ /*
+ * ${prop.xmlEncodedDescription}
+ * Raw ( bypadd bindings ) Getter for $prop.name
+ * @return $prop.name value from local variable
+ */
+ public $prop.simpleClassName ${prop.getterName}Raw()
+ {
+ return this._${prop.name};
+ }
+ #end
+ #end
+#end
+
+// Save state
+// ----------------------------------------------------- StateHolder Methods
+
+
+ public Object saveState(FacesContext context) {
+ Object values[] = new Object[${fiedCounter}];
+ values[0] = super.saveState(context);
+#set($currentField = 1)
+#foreach( $prop in $component.properties )
+ #if( !$prop.exist )
+ #if($prop.simpleType)
+ values[${currentField}] = new ${prop.boxingClass}(_$prop.name);
+ #set( $currentField = $currentField+1)
+ values[${currentField}] = Boolean.valueOf(_${prop.name}Set);
+ #set( $currentField = $currentField+1)
+ #else
+ #if(!${prop.attachedstate} )
+ values[${currentField}] = _$prop.name;
+ #else
+ values[${currentField}] = saveAttachedState(context, _$prop.name );
+ #end
+ #set( $currentField = $currentField+1)
+ #end
+ #end
+#end
+ return values;
+ }
+
+
+ public void restoreState(FacesContext context, Object state) {
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+#set($currentField = 1)
+#foreach( $prop in $component.properties )
+ #if( !$prop.exist )
+ #if($prop.simpleType)
+ _$prop.name =
((${prop.boxingClass})values[${currentField}]).${prop.classname}Value();
+ #set( $currentField = $currentField+1)
+ _${prop.name}Set = ((Boolean)values[${currentField}]).booleanValue();
+ #set( $currentField = $currentField+1)
+ #else
+ #if( !${prop.attachedstate} )
+ _$prop.name = (${prop.simpleClassName})values[${currentField}] ;
+ #else
+ _$prop.name =
(${prop.simpleClassName})restoreAttachedState(context,values[${currentField}] );
+ #end
+ #end
+ #set( $currentField = $currentField+1)
+ #end
+#end
+
+
+ }
+// Utilites
+
+}
Added: trunk/cdk/generator/src/main/resources/META-INF/templates/converterTag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/converterTag.vm
(rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/converterTag.vm 2007-04-24
10:22:53 UTC (rev 115)
@@ -0,0 +1,95 @@
+/**
+ * GENERATED FILE - DO NOT EDIT
+ *
+ */
+package ${tag.packageName};
+
+#foreach($import in $imports)
+import $import ;
+#end
+import javax.faces.component.UIComponent;
+import javax.faces.convert.Converter;
+import javax.faces.webapp.UIComponentTag;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import org.apache.commons.beanutils.ConvertUtils;
+import javax.servlet.jsp.JspException;
+import ${converter.classname};
+
+public class $tag.simpleClassName extends $tag.superclass
+{
+
+// Fields
+#foreach( $prop in $converter.properties )
+#if( !$prop.existintag )
+ /*
+ * $prop.name
+ * ${prop.xmlEncodedDescription}
+ */
+ private String _$prop.name = null;
+
+#end
+#end
+// Setters
+#foreach( $prop in $converter.properties )
+#if( !$prop.existintag )
+ /*
+ * $prop.description
+ * Setter for $prop.name
+ * @param $prop.name - new value
+ */
+ public void ${prop.setterName}(String __${prop.name})
+ {
+ this._${prop.name} = __${prop.name};
+ }
+
+#end
+#if( $prop.alias)
+ /*
+ * ${prop.xmlEncodedDescription}
+ * Setter for alias of $prop.name as $prop.alias
+ * @param $prop.name - new value
+ */
+ public void set${prop.upperFirstChar($prop.alias)}(String __${prop.alias})
+ {
+ this.${prop.setterName}(__${prop.alias});
+ }
+#end
+#end
+
+ protected Converter createConverter() throws JspException
+ {
+ ${converter.simpleClassName} converter = new ${converter.simpleClassName}();
+ _setProperties(converter);
+ return converter;
+ }
+
+ // Support method to wire in attributes
+ private void _setProperties(${converter.simpleClassName} converter) throws JspException
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+#foreach( $prop in $converter.properties )
+#if( !$prop.existintag )
+ if (_${prop.name} != null)
+ {
+#if( ${prop.el} )
+ if (UIComponentTag.isValueReference(_${prop.name}))
+ {
+ ValueBinding vb =
facesContext.getApplication().createValueBinding(_${prop.name});
+ converter.${prop.setterName}((${prop.simpleClassName})
vb.getValue(facesContext));
+ }
+#if (!${prop.elonly})
+ else
+ {
+ converter.${prop.setterName}((${prop.simpleClassName})
ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
+ }
+#end
+ }
+#else
+ converter.${prop.setterName}((${prop.simpleClassName})
ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
+#end
+#end
+#end
+ }
+
+}
Added: trunk/cdk/generator/src/main/resources/META-INF/templates/validator.vm
===================================================================
Added: trunk/cdk/generator/src/main/resources/META-INF/templates/validatorTag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/validatorTag.vm
(rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/validatorTag.vm 2007-04-24
10:22:53 UTC (rev 115)
@@ -0,0 +1,93 @@
+/**
+ * GENERATED FILE - DO NOT EDIT
+ *
+ */
+package ${tag.packageName};
+
+#foreach($import in $imports)
+import $import ;
+#end
+import javax.faces.component.UIComponent;
+import javax.faces.webapp.UIComponentTag;
+import javax.faces.validator.Validator;
+import org.apache.commons.beanutils.ConvertUtils;
+import javax.faces.context.FacesContext;
+import javax.servlet.jsp.JspException;
+import javax.faces.el.ValueBinding;
+import ${validator.classname};
+
+public class $tag.simpleClassName extends $tag.superclass {
+
+// Fields
+#foreach( $prop in $validator.properties )
+#if( !$prop.existintag )
+ /*
+ * $prop.name
+ * ${prop.xmlEncodedDescription}
+ */
+ private String _$prop.name = null;
+
+#end
+#end
+// Setters
+#foreach( $prop in $validator.properties )
+#if( !$prop.existintag )
+ /*
+ * $prop.description
+ * Setter for $prop.name
+ * @param $prop.name - new value
+ */
+ public void ${prop.setterName}( String __${prop.name} )
+ {
+ this._${prop.name} = __${prop.name};
+ }
+
+#end
+#if( $prop.alias)
+ /*
+ * ${prop.xmlEncodedDescription}
+ * Setter for alias of $prop.name as $prop.alias
+ * @param $prop.name - new value
+ */
+ public void set${prop.upperFirstChar($prop.alias)}( String __${prop.alias} )
+ {
+ this.${prop.setterName}(__${prop.alias});
+ }
+#end
+#end
+
+ protected Validator createValidator() throws JspException
+ {
+ ${validator.simpleClassName} validator = new ${validator.simpleClassName}();
+ _setProperties(validator);
+ return validator;
+ }
+
+ // Support method to wire in attributes
+ private void _setProperties(${validator.simpleClassName} validator) throws JspException
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+#foreach( $prop in $validator.properties )
+#if( !$prop.existintag )
+ if (_${prop.name} != null)
+ {
+#if( ${prop.el} )
+ if (UIComponentTag.isValueReference(_${prop.name}))
+ {
+ ValueBinding vb =
facesContext.getApplication().createValueBinding(_${prop.name});
+ validator.${prop.setterName}((${prop.simpleClassName})
vb.getValue(facesContext));
+ }
+#if (!${prop.elonly})
+ else
+ {
+ validator.${prop.setterName}((${prop.simpleClassName})
ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
+ }
+#end
+ }
+#else
+ validator.${prop.setterName}((${prop.simpleClassName})
ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
+#end
+#end
+#end
+ }
+}
Added: trunk/cdk/generator/src/main/resources/META-INF/templates12/validator.vm
===================================================================