JBoss Ajax4JSF SVN: r122 - in trunk/cdk/generator/src/main/resources/META-INF: templates12 and 1 other directory.
by ajax4jsf-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-04-24 20:24:54 -0400 (Tue, 24 Apr 2007)
New Revision: 122
Modified:
trunk/cdk/generator/src/main/resources/META-INF/templates/facelets.taglib.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/facelets.taglib.vm
Log:
listener tags generation added
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates/facelets.taglib.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/facelets.taglib.vm 2007-04-24 17:36:59 UTC (rev 121)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/facelets.taglib.vm 2007-04-25 00:24:54 UTC (rev 122)
@@ -28,4 +28,18 @@
</tag>
#end
#end
+
+
+#foreach( $listener in ${listeners})
+ <tag>
+ <tag-name>${listener.name}</tag-name>
+#if(${listener.taghandler})
+ <handler-class>
+ ${listener.taghandler.classname}
+ </handler-class>
+#end
+
+ </tag>
+#end
+
</facelet-taglib>
\ No newline at end of file
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/facelets.taglib.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/facelets.taglib.vm 2007-04-24 17:36:59 UTC (rev 121)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/facelets.taglib.vm 2007-04-25 00:24:54 UTC (rev 122)
@@ -52,4 +52,17 @@
#end
#end
+
+#foreach( $listener in ${listeners})
+ <tag>
+ <tag-name>${listener.name}</tag-name>
+#if(${listener.taghandler})
+ <handler-class>
+ ${listener.taghandler.classname}
+ </handler-class>
+#end
+
+ </tag>
+#end
+
</facelet-taglib>
\ No newline at end of file
17 years, 8 months
JBoss Ajax4JSF SVN: r121 - trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat.
by ajax4jsf-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-24 13:36:59 -0400 (Tue, 24 Apr 2007)
New Revision: 121
Modified:
trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
Log:
fix for a RF-111 bug
Modified: trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java
===================================================================
--- trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-04-24 17:22:14 UTC (rev 120)
+++ trunk/framework/src/main/java/org/ajax4jsf/ajax/repeat/UIDataAdaptor.java 2007-04-24 17:36:59 UTC (rev 121)
@@ -329,7 +329,8 @@
keys = (Set) (vb.getValue(getFacesContext()));
} else if(null != _ajaxRowKey){
// If none of above exist , use row with submitted AjaxComponent
- keys = (Collections.singleton(_ajaxRowKey));
+ keys = new HashSet(1);
+ keys.add(_ajaxRowKey);
}
}
return keys;
17 years, 8 months
JBoss Ajax4JSF SVN: r120 - trunk/cdk/compiler.
by ajax4jsf-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-24 13:22:14 -0400 (Tue, 24 Apr 2007)
New Revision: 120
Removed:
trunk/cdk/compiler/bin/
Log:
remove missed folder
17 years, 8 months
JBoss Ajax4JSF SVN: r118 - trunk/framework/src/main/config/component.
by ajax4jsf-svn-commits@lists.jboss.org
Author: vkukharchuk
Date: 2007-04-24 12:46:19 -0400 (Tue, 24 Apr 2007)
New Revision: 118
Modified:
trunk/framework/src/main/config/component/form.xml
trunk/framework/src/main/config/component/repeat.xml
Log:
Modified: trunk/framework/src/main/config/component/form.xml
===================================================================
--- trunk/framework/src/main/config/component/form.xml 2007-04-24 13:57:28 UTC (rev 117)
+++ trunk/framework/src/main/config/component/form.xml 2007-04-24 16:46:19 UTC (rev 118)
@@ -88,8 +88,10 @@
</displayname>
<icon>icon</icon>
</tag>
+
+ &html_universal_attributes;
&ui_command_attributes;
- &html_anchor_attributes;
+ &html_anchor_attributes;
&html_events;
</component>
</components>
\ No newline at end of file
Modified: trunk/framework/src/main/config/component/repeat.xml
===================================================================
--- trunk/framework/src/main/config/component/repeat.xml 2007-04-24 13:57:28 UTC (rev 117)
+++ trunk/framework/src/main/config/component/repeat.xml 2007-04-24 16:46:19 UTC (rev 118)
@@ -40,46 +40,35 @@
<displayname>Ajax-enabled repeater</displayname>
<icon>icon</icon>
</tag>
- &ui_data_attributes;
- <property>
- <name>varState</name>
- <classname>java.lang.String</classname>
- <description>varState</description>
- </property>
- <property>
- <name>value</name>
- <classname>java.lang.String</classname>
- <description>value</description>
- </property>
- <property>
- <name>componentState</name>
- <classname>java.lang.String</classname>
- <description>componentState</description>
- </property>
- <property>
- <name>rendered</name>
- <classname>boolean</classname>
- <description>rendered</description>
- </property>
- <property>
- <name>id</name>
- <classname>java.lang.String</classname>
- <description>id</description>
- </property>
- <property>
- <name>ajaxKeys</name>
- <classname>java.lang.String</classname>
- <description>ajaxKeys</description>
- </property>
- <property>
- <name>rowKey</name>
- <classname>java.lang.String</classname>
- <description>rowKey</description>
- </property>
- <property>
- <name>binding</name>
- <classname>java.lang.String</classname>
- <description>binding</description>
+ &ui_data_attributes;
+ &ui_component_attributes;
+ <property>
+ <name>varState</name>
+ <classname>java.lang.String</classname>
+ <description>varState</description>
</property>
+ <property>
+ <name>value</name>
+ <classname>java.lang.String</classname>
+ <description>The current value for this component.</description>
+ </property>
+ <property>
+ <name>componentState</name>
+ <classname>java.lang.String</classname>
+ <description>componentState</description>
+ </property>
+
+
+ <property>
+ <name>ajaxKeys</name>
+ <classname>java.lang.String</classname>
+ <description>This attribute defines strings that are updated after an AJAX request.</description>
+ </property>
+ <property>
+ <name>rowKey</name>
+ <classname>java.lang.String</classname>
+ <description>RowKey is a representation of an identifier for a specific data row.</description>
+ </property>
+
</component>
</components>
\ No newline at end of file
17 years, 8 months
JBoss Ajax4JSF SVN: r117 - trunk/framework/src/main/config/component.
by ajax4jsf-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-04-24 09:57:28 -0400 (Tue, 24 Apr 2007)
New Revision: 117
Modified:
trunk/framework/src/main/config/component/commandLink.xml
trunk/framework/src/main/config/component/form.xml
trunk/framework/src/main/config/component/include.xml
trunk/framework/src/main/config/component/mediaOutput.xml
trunk/framework/src/main/config/component/repeat.xml
trunk/framework/src/main/config/component/support.xml
Log:
Add needed attributes.
Modified: trunk/framework/src/main/config/component/commandLink.xml
===================================================================
--- trunk/framework/src/main/config/component/commandLink.xml 2007-04-24 13:49:46 UTC (rev 116)
+++ trunk/framework/src/main/config/component/commandLink.xml 2007-04-24 13:57:28 UTC (rev 117)
@@ -68,7 +68,8 @@
&ui_command_attributes;
&html_events;
&html_universal_attributes;
- &html_anchor_attributes;
+ &html_anchor_attributes;
+ &html_style_attributes;
&ajax_component_attributes;
<property>
<name>ignoreDupResponses</name>
Modified: trunk/framework/src/main/config/component/form.xml
===================================================================
--- trunk/framework/src/main/config/component/form.xml 2007-04-24 13:49:46 UTC (rev 116)
+++ trunk/framework/src/main/config/component/form.xml 2007-04-24 13:57:28 UTC (rev 117)
@@ -89,6 +89,7 @@
<icon>icon</icon>
</tag>
&ui_command_attributes;
- &html_anchor_attributes;
+ &html_anchor_attributes;
+ &html_events;
</component>
</components>
\ No newline at end of file
Modified: trunk/framework/src/main/config/component/include.xml
===================================================================
--- trunk/framework/src/main/config/component/include.xml 2007-04-24 13:49:46 UTC (rev 116)
+++ trunk/framework/src/main/config/component/include.xml 2007-04-24 13:57:28 UTC (rev 117)
@@ -36,7 +36,8 @@
<classname>org.ajax4jsf.taglib.html.facelets.IncludeHandler</classname>
</taghandler>
&ui_panel_attributes;
- &html_universal_attributes;
+ &html_universal_attributes;
+ &ajax_output_attributes;
<property>
<name>viewId</name>
<classname>java.lang.String</classname>
@@ -58,6 +59,26 @@
]]>
</description>
<defaultvalue>"inline"</defaultvalue>
+ </property>
+ <property>
+ <name>ajaxRendered</name>
+ <classname>boolean</classname>
+ <description>Defines, whether the content of this component must be
+ (or not) included in AJAX response created by parent
+ AJAX Container, even if it is not forced by reRender
+ list of ajax action. Ignored if component marked to
+ output by Ajax action. default false</description>
+ </property>
+ <property>
+ <name>keepTransient</name>
+ <classname>boolean</classname>
+ <description>Flag for mark all child components to non-transient. If
+ true, all children components will be set to non-transient state
+ and keep in saved components tree. For output in self-renderer
+ region all content ( By default, all content in &lt;f:verbatim&gt;
+ tags and non-jsf elements in facelets, marked as transient -
+ since, self-rendered ajax regions don't plain output for ajax
+ processing ).</description>
</property>
</component>
Modified: trunk/framework/src/main/config/component/mediaOutput.xml
===================================================================
--- trunk/framework/src/main/config/component/mediaOutput.xml 2007-04-24 13:49:46 UTC (rev 116)
+++ trunk/framework/src/main/config/component/mediaOutput.xml 2007-04-24 13:57:28 UTC (rev 117)
@@ -136,6 +136,33 @@
java.io.OutputStream.class,java.lang.Object.class
</methodargs>
</property>
-
+ <property>
+ <name>converter</name>
+ <classname>javax.faces.convert.Converter</classname>
+ <description>
+ ID of a converter to be used or a reference to a
+ converter.
+ </description>
+ </property>
+ <property>
+ <name>cacheable</name>
+ <classname>boolean</classname>
+ <description>cacheable</description>
+ </property>
+ <property>
+ <name>expires</name>
+ <classname>java.util.Date</classname>
+ <description>expires</description>
+ </property>
+ <property>
+ <name>session</name>
+ <classname>boolean</classname>
+ <description>session</description>
+ </property>
+ <property>
+ <name>lastModified</name>
+ <classname>java.util.Date</classname>
+ <description>lastModified</description>
+ </property>
</component>
</components>
\ No newline at end of file
Modified: trunk/framework/src/main/config/component/repeat.xml
===================================================================
--- trunk/framework/src/main/config/component/repeat.xml 2007-04-24 13:49:46 UTC (rev 116)
+++ trunk/framework/src/main/config/component/repeat.xml 2007-04-24 13:57:28 UTC (rev 117)
@@ -40,6 +40,46 @@
<displayname>Ajax-enabled repeater</displayname>
<icon>icon</icon>
</tag>
- &ui_data_attributes;
+ &ui_data_attributes;
+ <property>
+ <name>varState</name>
+ <classname>java.lang.String</classname>
+ <description>varState</description>
+ </property>
+ <property>
+ <name>value</name>
+ <classname>java.lang.String</classname>
+ <description>value</description>
+ </property>
+ <property>
+ <name>componentState</name>
+ <classname>java.lang.String</classname>
+ <description>componentState</description>
+ </property>
+ <property>
+ <name>rendered</name>
+ <classname>boolean</classname>
+ <description>rendered</description>
+ </property>
+ <property>
+ <name>id</name>
+ <classname>java.lang.String</classname>
+ <description>id</description>
+ </property>
+ <property>
+ <name>ajaxKeys</name>
+ <classname>java.lang.String</classname>
+ <description>ajaxKeys</description>
+ </property>
+ <property>
+ <name>rowKey</name>
+ <classname>java.lang.String</classname>
+ <description>rowKey</description>
+ </property>
+ <property>
+ <name>binding</name>
+ <classname>java.lang.String</classname>
+ <description>binding</description>
+ </property>
</component>
</components>
\ No newline at end of file
Modified: trunk/framework/src/main/config/component/support.xml
===================================================================
--- trunk/framework/src/main/config/component/support.xml 2007-04-24 13:49:46 UTC (rev 116)
+++ trunk/framework/src/main/config/component/support.xml 2007-04-24 13:57:28 UTC (rev 117)
@@ -115,6 +115,11 @@
<name>timeout</name>
<classname>int</classname>
<description>Timeout (in ms) for request</description>
+ </property>
+ <property>
+ <name>parentProperties</name>
+ <classname>java.lang.String</classname>
+ <description>parentProperties</description>
</property>
</component>
17 years, 8 months
JBoss Ajax4JSF SVN: r115 - in trunk/cdk/generator/src/main/resources/META-INF: templates12 and 1 other directory.
by ajax4jsf-svn-commits@lists.jboss.org
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
===================================================================
17 years, 8 months
JBoss Ajax4JSF SVN: r114 - in trunk/cdk: compiler/bin and 17 other directories.
by ajax4jsf-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-23 20:51:23 -0400 (Mon, 23 Apr 2007)
New Revision: 114
Added:
trunk/cdk/compiler/bin/
trunk/cdk/compiler/bin/.svnignore
trunk/cdk/compiler/bin/pom.xml
trunk/cdk/compiler/bin/src/
trunk/cdk/compiler/bin/src/main/
trunk/cdk/compiler/bin/src/main/java/
trunk/cdk/compiler/bin/src/main/java/org/
trunk/cdk/compiler/bin/src/main/java/readme.txt
trunk/cdk/compiler/bin/src/main/resources/
trunk/cdk/compiler/bin/src/main/resources/META-INF/
trunk/cdk/compiler/bin/src/main/resources/org/
trunk/cdk/compiler/bin/src/test/
trunk/cdk/compiler/bin/src/test/java/
trunk/cdk/compiler/bin/src/test/java/org/
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBaseBean.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ConverterBean.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ValidatorBean.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTagGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ConverterGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ConverterTagGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ValidatorGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ValidatorTagGenerator.java
trunk/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/converter.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/converterTag.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/validatorTag.vm
trunk/cdk/maven-cdk-plugin/bin/
trunk/cdk/maven-cdk-plugin/bin/.svnignore
trunk/cdk/maven-cdk-plugin/bin/pom.xml
trunk/cdk/maven-cdk-plugin/bin/src/
trunk/cdk/maven-cdk-plugin/bin/src/main/
trunk/cdk/maven-cdk-plugin/bin/src/main/java/
trunk/cdk/maven-cdk-plugin/bin/src/main/resources/
trunk/cdk/maven-cdk-plugin/bin/src/site/
trunk/cdk/maven-cdk-plugin/bin/src/site/apt/
trunk/cdk/maven-cdk-plugin/bin/src/site/resources/
trunk/cdk/maven-cdk-plugin/bin/src/site/site.xml
Removed:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagGenerator.java
trunk/cdk/generator/src/main/resources/META-INF/templates12/tag.vm
Modified:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/ant/JSFGeneratorTask.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/BuilderConfig.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBean.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/BlankRendererGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTestGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/FaceletsTaglibGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/FacesConfigGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/InnerGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/RendererGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagHandlerGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagTestGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TaglibGenerator.java
trunk/cdk/generator/src/main/resources/META-INF/schema/component-config.dtd
trunk/cdk/generator/src/main/resources/META-INF/templates12/facelets.taglib.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/faces-config.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/taglib.vm
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateMojo.java
Log:
apply RF-12 patch, generate JSF converters and validators.
Added: trunk/cdk/compiler/bin/.svnignore
===================================================================
--- trunk/cdk/compiler/bin/.svnignore (rev 0)
+++ trunk/cdk/compiler/bin/.svnignore 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1 @@
+target
Added: trunk/cdk/compiler/bin/pom.xml
===================================================================
--- trunk/cdk/compiler/bin/pom.xml (rev 0)
+++ trunk/cdk/compiler/bin/pom.xml 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1,63 @@
+<?xml version="1.0"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>cdk</artifactId>
+ <groupId>org.ajax4jsf</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.ajax4jsf.cdk</groupId>
+ <artifactId>compiler</artifactId>
+ <name>JSF Renderers templates complier</name>
+ <url>http://labs.jboss.com/wiki/Ajax4jsf/cdk/compiler</url>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ <version>1.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>velocity</groupId>
+ <artifactId>velocity-dep</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>el-impl</groupId>
+ <artifactId>el-impl</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/cdk/compiler/bin/src/main/java/readme.txt
===================================================================
--- trunk/cdk/compiler/bin/src/main/java/readme.txt (rev 0)
+++ trunk/cdk/compiler/bin/src/main/java/readme.txt 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1 @@
+Component development kit
\ No newline at end of file
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/ant/JSFGeneratorTask.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/ant/JSFGeneratorTask.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/ant/JSFGeneratorTask.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,401 +1,401 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.ant;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ParsingException;
-import org.ajax4jsf.builder.generator.ComponentGenerator;
-import org.ajax4jsf.builder.generator.FaceletsTaglibGenerator;
-import org.ajax4jsf.builder.generator.FacesConfigGenerator;
-import org.ajax4jsf.builder.generator.GeneratorException;
-import org.ajax4jsf.builder.generator.InnerGenerator;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.generator.ListenerGenerator;
-import org.ajax4jsf.builder.generator.RendererGenerator;
-import org.ajax4jsf.builder.generator.TagGenerator;
-import org.ajax4jsf.builder.generator.TagHandlerGenerator;
-import org.ajax4jsf.builder.generator.TaglibGenerator;
-import org.ajax4jsf.builder.velocity.BuilderContext;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.taskdefs.Ant.Reference;
-import org.apache.tools.ant.types.FileList;
-import org.apache.tools.ant.types.Path;
-import org.apache.velocity.Template;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
-
-
-/**
- * Base Task for build componenta,renderers,faces-config,tag and tld files.
- * for use in ant build.xml , task must be defined as :
- * <taskdef classpathref="taskClassPath"
- * classname="com.exadel.vcp.builder.ant.JSFGeneratorTask"
- * name="jsfgenerator">
- * Where classpath for task must contain component-builder.jar, velocity-dep.jar
- * commons-beanutils.jar and commons-digister.jar . This Task use JDK 1.5
- * To invoke task , put
- * <jsfgenerator configfile="../conf/test.xml"
- * destdir="../generated"
- * description="Build classes and configs" >
- * ....
- * </jsfgenerator>
- * mantadory attributes :
- * configfile - point to xml configuration file with components descriptions. For detail of configuration,
- * see {@link META-INF/schema/component-config.dtd} and {@link org.ajax4jsf.builder.config.ComponentBean}
- * also, can use instead {@link org.apache.tools.ant.types.FileList} type child element <configs> with other config files,
- * for syntax see Ant <folelist> element
- * optional attributes :
- * destdir - destination directory for generated files. If not set, must be set in nesting generation elements.
- * templates - directory with custom templates. If template not found in this directory, use default fom jar
- * classpath, classpathref - classpath definition for load components,tags,renderers classes for analaize properties
- * for generation of concrete files, used nested elements :
- * <components> generate components implementation classes {@see com.exadel.vcp.builder.ant.ComponentGenerator}
- * <renderers> generate renderers implementation classes {@see com.exadel.vcp.builder.ant.RendererGenerator}
- * <tags> generate jsp tags implementation classes {@see com.exadel.vcp.builder.ant.TagGenerator}
- * <facesconfig> - generate jsf configuration file {@see com.exadel.vcp.builder.ant.FacesConfigGenerator}
- * <taglib> generate taglib .tld file {@see com.exadel.vcp.builder.ant.TaglibGenerator}
- * <faceletstaglib> - generate taglib for facelets {@see com.exadel.vcp.builder.ant.FaceletsTaglibGenerator}
- * also, can use nested <classpath> element, same as javac ant task
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.11 $ $Date: 2007/02/26 20:49:03 $
- *
- */
-public class JSFGeneratorTask extends Task implements JSFGeneratorConfiguration {
-
- private FileList _configs;
- /**
- * Configuration file for build
- */
- private File configFile;
- /**
- * Destination to place sources and config files
- */
- private File destDir;
-
- /**
- * Directory for velocity templates
- */
- private File templates;
-
- /**
- * Classpath for load components and other generation-related classes.
- */
- private Path _classpath;
-
-
- private BuilderConfig _config = null;
-
- private List<InnerGenerator> _inners = new ArrayList<InnerGenerator>();
-
- private String key;
-
- private String templatesPath=BuilderContext.TEMPLATES_PATH;
- /**
- * @return Returns the configFile.
- */
- public File getConfigFile() {
- return configFile;
- }
-
- /**
- * @param configFile The configFile to set.
- */
- public void setConfigFile(File configFile) {
- this.configFile = configFile;
- }
-
-
- /**
- * Create child element for list of config files.
- * Task Can have only one such child
- * @return
- */
- public FileList createConfigs() {
- this._configs = new FileList();
- return _configs;
- }
- /* (non-Javadoc)
- * @see org.ajax4jsf.builder.ant.JSFGeneratorConfiguration#getDestDir()
- */
- public File getDestDir() {
- return destDir;
- }
-
- /**
- * @param destDir The destDir to set.
- */
- public void setDestDir(File destDir) {
- this.destDir = destDir;
- }
-
- /**
- * @return Returns the templates.
- */
- public File getTemplates() {
- return templates;
- }
-
- /**
- * @param templates The templates to set.
- */
- public void setTemplates(File templates) {
- this.templates = templates;
- }
-
- /**
- * @return Returns the classpath.
- */
- public Path getClasspath() {
- return _classpath;
- }
-
- /**
- * @param classpath The classpath to set.
- */
- public void setClasspath(Path classpath) {
- if(null == _classpath) {
- _classpath = classpath;
- } else {
- _classpath.add(classpath);
- }
- }
-
- public Path createClasspath() {
- Path classpath = new Path(getProject());
- if(null == _classpath) {
- _classpath = classpath;
- } else {
- _classpath.add(classpath);
- }
- return classpath;
- }
-
- public void setClasspathRef(Reference ref) {
- Object refObj = ref.getReferencedObject();
- if (refObj instanceof Path) {
- setClasspath( (Path) refObj );
- }
- }
- final private static String VELOCITY_PROPERTIES = "velocity.properties";
-
-
- private VelocityEngine engine;
-
- private Map<String, Template> _templates = new HashMap<String, Template>();
-
-
- public void init() throws BuildException {
- super.init();
- Properties velocityProperties = new Properties();
- try {
- InputStream streamVelosityProperties = JSFGeneratorTask.class.getResourceAsStream(VELOCITY_PROPERTIES);
- velocityProperties.load(streamVelosityProperties);
- engine = new VelocityEngine();
- engine.init(velocityProperties);
- } catch(Exception e){
- throw new BuildException("Error init velocity engine",e);
- }
- }
-
- public Template getTemplate(String name) throws GeneratorException {
- Template template = _templates.get(name);
- if(null == template){
- try {
- template = engine.getTemplate(name);
- } catch (ResourceNotFoundException e) {
- throw new GeneratorException(e.getLocalizedMessage());
- } catch (ParseErrorException e) {
- throw new GeneratorException(e.getLocalizedMessage());
- } catch (Exception e) {
- throw new GeneratorException(e.getLocalizedMessage());
- }
- _templates.put(name, template);
- }
- return template;
- }
-
-
- /* (non-Javadoc)
- * @see org.apache.tools.ant.Task#execute()
- */
- public void execute() throws BuildException {
- BuilderConfig config;
- config = getBuilderConfig();
- for (Iterator<InnerGenerator> it = _inners.iterator(); it.hasNext();) {
- InnerGenerator generator = it.next();
- getProject().log("Build files for subtask "+generator.getClass().getSimpleName());
- try {
- generator.createFiles(config);
- } catch (Exception e) {
- getProject().log("Error for buid files by builder "+generator.getClass().getSimpleName(),Project.MSG_ERR);
- e.printStackTrace();
- throw new BuildException("Error for buid files by builder "+generator.getClass().getSimpleName(),e);
- }
- }
- }
-
- /**
- * Lazy parsing and creation of builder configuration.
- * @param config
- * @return
- * @throws BuildException
- */
- private BuilderConfig getBuilderConfig() throws BuildException {
- if (null == _config) {
- // Test real configuration
- if (getConfigFile() == null && getConfigs() == null) {
- throw new BuildException("Config file name not set");
- }
- // Init Velocity
- try {
- BuilderContext.init(getTemplates());
- } catch (GeneratorException e1) {
- throw new BuildException(e1);
- }
- // Parse configuration
- try {
- _config = new BuilderConfig(getClassLoader(),new AntLogger(this));
- if (null != getConfigFile()) {
- _config.parseConfig(getConfigFile());
- }
- if(null != getConfigs()) {
- String[] files = getConfigs().getFiles(getProject());
- for (int i = 0; i < files.length; i++) {
- String file = files[i];
- _config.parseConfig(new File(getConfigs().getDir(getProject()),file));
- }
- }
- _config.checkComopnentProperties();
- } catch (ParsingException e) {
- e.printStackTrace();
- throw new BuildException("Error building ", e);
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- throw new BuildException("Error building ", e);
- }
- }
- return _config;
- }
-
- public ClassLoader getClassLoader() {
- return getProject().createClassLoader(getClasspath());
- }
-
- public ComponentGenerator createComponents() {
- ComponentGenerator generator = new ComponentGenerator(this,new AntLogger(this));
- _inners.add(generator);
- return generator;
- }
-
- public FacesConfigGenerator createFacesconfig() {
- FacesConfigGenerator generator = new FacesConfigGenerator(this,new AntLogger(this));
- _inners.add(generator);
- return generator;
- }
- public RendererGenerator createRenderers() {
- RendererGenerator generator = new RendererGenerator(this,new AntLogger(this));
- _inners.add(generator);
- return generator;
- }
- public TagGenerator createTags() {
- TagGenerator generator = new TagGenerator(this,new AntLogger(this));
- _inners.add(generator);
- return generator;
- }
- public TaglibGenerator createTaglib() {
- TaglibGenerator generator = new TaglibGenerator(this,new AntLogger(this));
- _inners.add(generator);
- return generator;
- }
-
- public FaceletsTaglibGenerator createFaceletsTaglib() {
- FaceletsTaglibGenerator generator = new FaceletsTaglibGenerator(this,new AntLogger(this));
- _inners.add(generator);
- return generator;
- }
-
- public TagHandlerGenerator createTagHandler() {
- TagHandlerGenerator generator = new TagHandlerGenerator(this,new AntLogger(this));
- _inners.add(generator);
- return generator;
- }
-
- public ListenerGenerator createListenerGenerator() {
- ListenerGenerator generator = new ListenerGenerator(this, new AntLogger(this));
- _inners.add(generator);
- return generator;
- }
-
- /**
- * @return Returns the configs.
- */
- private FileList getConfigs() {
- return _configs;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.builder.ant.JSFGeneratorConfiguration#getKey()
- */
- public String getKey() {
- return this.key;
- }
-
- /**
- * @param key The key to set.
- */
- public void setKey(String key) {
- this.key = key;
- if(key != null && key.length() == 0){
- this.key = null;
- }
-
- }
-
- /**
- * @return the templatesPath
- */
- public String getTemplatesPath() {
- return this.templatesPath;
- }
-
- /**
- * @param templatesPath the templatesPath to set
- */
- public void setTemplatesPath(String templatesPath) {
- this.templatesPath = templatesPath;
- }
-
-
-}
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.ant;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ParsingException;
+import org.ajax4jsf.builder.generator.ComponentGenerator;
+import org.ajax4jsf.builder.generator.FaceletsTaglibGenerator;
+import org.ajax4jsf.builder.generator.FacesConfigGenerator;
+import org.ajax4jsf.builder.generator.GeneratorException;
+import org.ajax4jsf.builder.generator.InnerGenerator;
+import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
+import org.ajax4jsf.builder.generator.ListenerGenerator;
+import org.ajax4jsf.builder.generator.RendererGenerator;
+import org.ajax4jsf.builder.generator.ComponentTagGenerator;
+import org.ajax4jsf.builder.generator.TagHandlerGenerator;
+import org.ajax4jsf.builder.generator.TaglibGenerator;
+import org.ajax4jsf.builder.velocity.BuilderContext;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Ant.Reference;
+import org.apache.tools.ant.types.FileList;
+import org.apache.tools.ant.types.Path;
+import org.apache.velocity.Template;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+
+
+/**
+ * Base Task for build componenta,renderers,faces-config,tag and tld files.
+ * for use in ant build.xml , task must be defined as :
+ * <taskdef classpathref="taskClassPath"
+ * classname="com.exadel.vcp.builder.ant.JSFGeneratorTask"
+ * name="jsfgenerator">
+ * Where classpath for task must contain component-builder.jar, velocity-dep.jar
+ * commons-beanutils.jar and commons-digister.jar . This Task use JDK 1.5
+ * To invoke task , put
+ * <jsfgenerator configfile="../conf/test.xml"
+ * destdir="../generated"
+ * description="Build classes and configs" >
+ * ....
+ * </jsfgenerator>
+ * mantadory attributes :
+ * configfile - point to xml configuration file with components descriptions. For detail of configuration,
+ * see {@link META-INF/schema/component-config.dtd} and {@link org.ajax4jsf.builder.config.ComponentBean}
+ * also, can use instead {@link org.apache.tools.ant.types.FileList} type child element <configs> with other config files,
+ * for syntax see Ant <folelist> element
+ * optional attributes :
+ * destdir - destination directory for generated files. If not set, must be set in nesting generation elements.
+ * templates - directory with custom templates. If template not found in this directory, use default fom jar
+ * classpath, classpathref - classpath definition for load components,tags,renderers classes for analaize properties
+ * for generation of concrete files, used nested elements :
+ * <components> generate components implementation classes {@see com.exadel.vcp.builder.ant.ComponentGenerator}
+ * <renderers> generate renderers implementation classes {@see com.exadel.vcp.builder.ant.RendererGenerator}
+ * <tags> generate jsp tags implementation classes {@see com.exadel.vcp.builder.ant.TagGenerator}
+ * <facesconfig> - generate jsf configuration file {@see com.exadel.vcp.builder.ant.FacesConfigGenerator}
+ * <taglib> generate taglib .tld file {@see com.exadel.vcp.builder.ant.TaglibGenerator}
+ * <faceletstaglib> - generate taglib for facelets {@see com.exadel.vcp.builder.ant.FaceletsTaglibGenerator}
+ * also, can use nested <classpath> element, same as javac ant task
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.11 $ $Date: 2007/02/26 20:49:03 $
+ *
+ */
+public class JSFGeneratorTask extends Task implements JSFGeneratorConfiguration {
+
+ private FileList _configs;
+ /**
+ * Configuration file for build
+ */
+ private File configFile;
+ /**
+ * Destination to place sources and config files
+ */
+ private File destDir;
+
+ /**
+ * Directory for velocity templates
+ */
+ private File templates;
+
+ /**
+ * Classpath for load components and other generation-related classes.
+ */
+ private Path _classpath;
+
+
+ private BuilderConfig _config = null;
+
+ private List<InnerGenerator> _inners = new ArrayList<InnerGenerator>();
+
+ private String key;
+
+ private String templatesPath=BuilderContext.TEMPLATES_PATH;
+ /**
+ * @return Returns the configFile.
+ */
+ public File getConfigFile() {
+ return configFile;
+ }
+
+ /**
+ * @param configFile The configFile to set.
+ */
+ public void setConfigFile(File configFile) {
+ this.configFile = configFile;
+ }
+
+
+ /**
+ * Create child element for list of config files.
+ * Task Can have only one such child
+ * @return
+ */
+ public FileList createConfigs() {
+ this._configs = new FileList();
+ return _configs;
+ }
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.ant.JSFGeneratorConfiguration#getDestDir()
+ */
+ public File getDestDir() {
+ return destDir;
+ }
+
+ /**
+ * @param destDir The destDir to set.
+ */
+ public void setDestDir(File destDir) {
+ this.destDir = destDir;
+ }
+
+ /**
+ * @return Returns the templates.
+ */
+ public File getTemplates() {
+ return templates;
+ }
+
+ /**
+ * @param templates The templates to set.
+ */
+ public void setTemplates(File templates) {
+ this.templates = templates;
+ }
+
+ /**
+ * @return Returns the classpath.
+ */
+ public Path getClasspath() {
+ return _classpath;
+ }
+
+ /**
+ * @param classpath The classpath to set.
+ */
+ public void setClasspath(Path classpath) {
+ if(null == _classpath) {
+ _classpath = classpath;
+ } else {
+ _classpath.add(classpath);
+ }
+ }
+
+ public Path createClasspath() {
+ Path classpath = new Path(getProject());
+ if(null == _classpath) {
+ _classpath = classpath;
+ } else {
+ _classpath.add(classpath);
+ }
+ return classpath;
+ }
+
+ public void setClasspathRef(Reference ref) {
+ Object refObj = ref.getReferencedObject();
+ if (refObj instanceof Path) {
+ setClasspath( (Path) refObj );
+ }
+ }
+ final private static String VELOCITY_PROPERTIES = "velocity.properties";
+
+
+ private VelocityEngine engine;
+
+ private Map<String, Template> _templates = new HashMap<String, Template>();
+
+
+ public void init() throws BuildException {
+ super.init();
+ Properties velocityProperties = new Properties();
+ try {
+ InputStream streamVelosityProperties = JSFGeneratorTask.class.getResourceAsStream(VELOCITY_PROPERTIES);
+ velocityProperties.load(streamVelosityProperties);
+ engine = new VelocityEngine();
+ engine.init(velocityProperties);
+ } catch(Exception e){
+ throw new BuildException("Error init velocity engine",e);
+ }
+ }
+
+ public Template getTemplate(String name) throws GeneratorException {
+ Template template = _templates.get(name);
+ if(null == template){
+ try {
+ template = engine.getTemplate(name);
+ } catch (ResourceNotFoundException e) {
+ throw new GeneratorException(e.getLocalizedMessage());
+ } catch (ParseErrorException e) {
+ throw new GeneratorException(e.getLocalizedMessage());
+ } catch (Exception e) {
+ throw new GeneratorException(e.getLocalizedMessage());
+ }
+ _templates.put(name, template);
+ }
+ return template;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.tools.ant.Task#execute()
+ */
+ public void execute() throws BuildException {
+ BuilderConfig config;
+ config = getBuilderConfig();
+ for (Iterator<InnerGenerator> it = _inners.iterator(); it.hasNext();) {
+ InnerGenerator generator = it.next();
+ getProject().log("Build files for subtask "+generator.getClass().getSimpleName());
+ try {
+ generator.createFiles(config);
+ } catch (Exception e) {
+ getProject().log("Error for buid files by builder "+generator.getClass().getSimpleName(),Project.MSG_ERR);
+ e.printStackTrace();
+ throw new BuildException("Error for buid files by builder "+generator.getClass().getSimpleName(),e);
+ }
+ }
+ }
+
+ /**
+ * Lazy parsing and creation of builder configuration.
+ * @param config
+ * @return
+ * @throws BuildException
+ */
+ private BuilderConfig getBuilderConfig() throws BuildException {
+ if (null == _config) {
+ // Test real configuration
+ if (getConfigFile() == null && getConfigs() == null) {
+ throw new BuildException("Config file name not set");
+ }
+ // Init Velocity
+ try {
+ BuilderContext.init(getTemplates());
+ } catch (GeneratorException e1) {
+ throw new BuildException(e1);
+ }
+ // Parse configuration
+ try {
+ _config = new BuilderConfig(getClassLoader(),new AntLogger(this));
+ if (null != getConfigFile()) {
+ _config.parseConfig(getConfigFile());
+ }
+ if(null != getConfigs()) {
+ String[] files = getConfigs().getFiles(getProject());
+ for (int i = 0; i < files.length; i++) {
+ String file = files[i];
+ _config.parseConfig(new File(getConfigs().getDir(getProject()),file));
+ }
+ }
+ _config.checkComopnentProperties();
+ } catch (ParsingException e) {
+ e.printStackTrace();
+ throw new BuildException("Error building ", e);
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ throw new BuildException("Error building ", e);
+ }
+ }
+ return _config;
+ }
+
+ public ClassLoader getClassLoader() {
+ return getProject().createClassLoader(getClasspath());
+ }
+
+ public ComponentGenerator createComponents() {
+ ComponentGenerator generator = new ComponentGenerator(this,new AntLogger(this));
+ _inners.add(generator);
+ return generator;
+ }
+
+ public FacesConfigGenerator createFacesconfig() {
+ FacesConfigGenerator generator = new FacesConfigGenerator(this,new AntLogger(this));
+ _inners.add(generator);
+ return generator;
+ }
+ public RendererGenerator createRenderers() {
+ RendererGenerator generator = new RendererGenerator(this,new AntLogger(this));
+ _inners.add(generator);
+ return generator;
+ }
+ public ComponentTagGenerator createTags() {
+ ComponentTagGenerator generator = new ComponentTagGenerator(this,new AntLogger(this));
+ _inners.add(generator);
+ return generator;
+ }
+ public TaglibGenerator createTaglib() {
+ TaglibGenerator generator = new TaglibGenerator(this,new AntLogger(this));
+ _inners.add(generator);
+ return generator;
+ }
+
+ public FaceletsTaglibGenerator createFaceletsTaglib() {
+ FaceletsTaglibGenerator generator = new FaceletsTaglibGenerator(this,new AntLogger(this));
+ _inners.add(generator);
+ return generator;
+ }
+
+ public TagHandlerGenerator createTagHandler() {
+ TagHandlerGenerator generator = new TagHandlerGenerator(this,new AntLogger(this));
+ _inners.add(generator);
+ return generator;
+ }
+
+ public ListenerGenerator createListenerGenerator() {
+ ListenerGenerator generator = new ListenerGenerator(this, new AntLogger(this));
+ _inners.add(generator);
+ return generator;
+ }
+
+ /**
+ * @return Returns the configs.
+ */
+ private FileList getConfigs() {
+ return _configs;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.ant.JSFGeneratorConfiguration#getKey()
+ */
+ public String getKey() {
+ return this.key;
+ }
+
+ /**
+ * @param key The key to set.
+ */
+ public void setKey(String key) {
+ this.key = key;
+ if(key != null && key.length() == 0){
+ this.key = null;
+ }
+
+ }
+
+ /**
+ * @return the templatesPath
+ */
+ public String getTemplatesPath() {
+ return this.templatesPath;
+ }
+
+ /**
+ * @param templatesPath the templatesPath to set
+ */
+ public void setTemplatesPath(String templatesPath) {
+ this.templatesPath = templatesPath;
+ }
+
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/BuilderConfig.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/BuilderConfig.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/BuilderConfig.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,440 +1,540 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.config;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.naming.ConfigurationException;
-
-import org.ajax4jsf.builder.generator.Logger;
-import org.apache.commons.digester.Digester;
-import org.apache.commons.digester.ExtendedBaseRules;
-import org.apache.tools.ant.BuildException;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.EntityResolver2;
-
-/**
- * Parse builder config file for use with component creation.
- * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.10 $ $Date: 2007/02/20 20:57:58 $
- *
- */
-public class BuilderConfig implements LoaderHolder {
-
-
- /**
- * Resource path to config file schemas and entities
- */
- public static final String COMPONENT_SCHEMA_BASE = "/META-INF/schema/";
- /**
- * Resource path to config file schemas and entities
- */
- public static final String ENTITIES_FOLDER = "entities";
- /**
- * default URI to dtd in classpath
- */
- private static final String COMPONENT_CONFIG_DTD_URI = COMPONENT_SCHEMA_BASE+"component-config.dtd";
- /**
- * root element of configuration file
- */
- private static final String GENERATOR_CONFIG_ROOT_ELEMENT = "components";
- /**
- * PUBLIC Id of configuration schema
- */
- private static final String GENERATOR_CONFIG_PUBLIC_ID = "-//AJAX4JSF//CDK Generator config/EN";
- /**
- * components described in this configuration
- */
- private List<ComponentBean> components = new ArrayList<ComponentBean>();
-
- /**
- * renderers described in this configuration
- */
- private List<RendererBean> renderers = new ArrayList<RendererBean>();
-
- private List<ListenerBean> listeners = new ArrayList<ListenerBean>();
-
- private ClassLoader _loader;
-
- private Logger _log;
-
- /**
- * @param project - current ant project
- */
- public BuilderConfig(ClassLoader loader, Logger log) {
- _loader = loader;
- _log = log;
- }
-
- /**
- * Parsing builder configuration file
- * @param configFile
- * @throws ParsingException
- */
- public void parseConfig(final File configFile) throws ParsingException {
- getLog().info(" Parse config file "+configFile.toString());
- Digester digester = new Digester();
- digester.setRules( new ExtendedBaseRules() );
- digester.setValidating(false);
- digester.setNamespaceAware(false);
-// try {
- //URL dtd = this.getClass().getClassLoader().getResource(COMPONENT_CONFIG_DTD_URI);
- //new URL("resource:/com/exadel/vcp/builder/config/component-config.dtd");
- getLog().debug("Register config DTD as URI "+COMPONENT_CONFIG_DTD_URI);
- digester.register(GENERATOR_CONFIG_PUBLIC_ID, COMPONENT_CONFIG_DTD_URI);
-// } catch (MalformedURLException e) {
-// throw new ParsingException("Malformed URL for internal DTD reference",e);
-// }
-
- // setup custom entity resolver for handle file-resource path's
- // resolve DTD even it not pointed in file, and, for entities - resolve it in
- // classpath if entity registered in DTD witn path /META-INF/schema
- digester.setEntityResolver(new EntityResolver2() {
-
- /* (non-Javadoc)
- * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
- */
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
- getLog().debug("Request for entity with systemId "+systemId+" and publicId "+publicId);
- if (GENERATOR_CONFIG_PUBLIC_ID.equals(publicId)) {
- return getDTDSource();
- } else if(null != publicId && null != systemId && systemId.contains(ENTITIES_FOLDER)){
- int base = systemId.indexOf(ENTITIES_FOLDER);
- String entity = COMPONENT_SCHEMA_BASE+systemId.substring(base);
- getLog().debug("attempt to load entity from classpath "+entity);
- InputStream entityStream = BuilderConfig.class
- .getResourceAsStream(entity);
- if (null != entityStream) {
- return new InputSource(entityStream);
- }
- }
- return null;
- }
-
- public InputSource getExternalSubset(String name, String baseURI) throws SAXException, IOException {
- getLog().debug("Request for ExternalSubset with name "+name+" and baseURI "+baseURI);
- if (GENERATOR_CONFIG_ROOT_ELEMENT.equals(name)) {
- return getDTDSource();
- }
- return null;
- }
-
- public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException {
- getLog().debug("Request for extended entity with systemId "+systemId+" and publicId "+publicId);
- getLog().debug("additional parameters with name "+name+" and baseURI "+baseURI);
- if ("[dtd]".equals(name) && GENERATOR_CONFIG_PUBLIC_ID.equals(publicId)) {
- return getDTDSource();
- }
- else if (null==name || (!name.startsWith("[") && !name.startsWith("&"))) {
- return resolveEntity(publicId,systemId);
- }
- return null;
- }
-
- /**
- * Resolve config DTD from classpath
- * @return source of config file DTD
- */
- private InputSource getDTDSource() {
- return new InputSource(BuilderConfig.class.getResourceAsStream(COMPONENT_CONFIG_DTD_URI));
- }
-
- });
-
- // Parsing rules.
- String path = "components/component";
- digester.addObjectCreate(path, ComponentBean.class);
- digester.addBeanPropertySetter(path+"/name");
- digester.addBeanPropertySetter(path+"/family");
- digester.addBeanPropertySetter(path+"/classname");
- digester.addBeanPropertySetter(path+"/superclass");
- digester.addBeanPropertySetter(path+"/description");
- digester.addBeanPropertySetter(path+"/displayname");
- digester.addBeanPropertySetter(path+"/icon");
- // TODO - for superclass, populate from description in config file, if exist
- digester.addSetProperties(path);
- digester.addSetNext(path, "addComponent");
- path = "components/renderer";
- digester.addObjectCreate(path, RendererBean.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "addRenderer");
- path = "components/component/renderer";
- digester.addObjectCreate(path, RendererBean.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "setRenderer");
- path = "components/component/tag";
- digester.addObjectCreate(path, TagBean.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "setTag");
-
- path = "components/component/tag/test";
- digester.addObjectCreate(path, TestClassHolder.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "setTest");
-
- path = "components/component/test";
- digester.addObjectCreate(path, TestClassHolder.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "setTest");
-
- path = "components/component/taghandler";
- digester.addObjectCreate(path, TagHandlerBean.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "setTaghandler");
-/*
- path = "components/component/taghandler/test";
- digester.addObjectCreate(path, TestClassHolder.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "setTest");
-*/
- path = "components/component/facet";
- digester.addObjectCreate(path, JsfBean.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "addFacet");
- path = "components/component/event";
- digester.addObjectCreate(path, EventBean.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "addEvent");
- path = "components/component/property";
- digester.addObjectCreate(path, PropertyBean.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "addProperty");
- path = "*/properties/property";
- digester.addObjectCreate(path, PropertyBean.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "addProperty");
-
- path = "components/listener";
- digester.addObjectCreate(path, ListenerBean.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "addListener");
- path = "components/listener/tag";
- digester.addObjectCreate(path, TagBean.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "setTag");
- path = "components/listener/taghandler";
- digester.addObjectCreate(path, TagHandlerBean.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "setTaghandler");
- path = "components/listener/property";
- digester.addObjectCreate(path, PropertyBean.class);
- digester.addBeanPropertySetter(path+"/?");
- digester.addSetProperties(path);
- digester.addSetNext(path, "addProperty");
-
- // Set this config as root.
- digester.push(this);
- try {
- digester.parse(configFile.toString());
- } catch (IOException e) {
- // TODO Auto-generated catch block
- throw new ParsingException("I/O error on parsing config file ",e);
- } catch (SAXException e) {
- // TODO Auto-generated catch block
- throw new ParsingException("SAX Parsing error in config file ",e);
- }
-// checkComopnentProperties();
-// return this;
- }
-
- /**
- * Check all components for existing and default properties.
- * @param classpath - classpath to find user components, renderers, tags
- * @throws ConfigurationException
- */
- public void checkComopnentProperties() throws ParsingException {
-// ClassLoader loader = getProject().createClassLoader(classpath);
-// if(null == loader) {
-// loader = this.getClass().getClassLoader();
-// }
-// setLoader(loader);
-
- for (ListenerBean listener : getListeners()) {
- try {
- Class<?> listenerClass = Class.forName(listener.getComponentclass(), false, getLoader());
- for (ComponentBean bean : getComponents()) {
- if (bean.getSuperclass() != null) {
- Class<?> componentSClass = Class.forName(bean.getSuperclass(), false, getLoader());
-
- if (listenerClass.isAssignableFrom(componentSClass)) {
-
- PropertyBean listenerProperty = new PropertyBean();
- listenerProperty.setClassname("javax.faces.el.MethodBinding");
- listenerProperty.setEl(true);
- listenerProperty.setElonly(true);
- listenerProperty.setName(listener.getName());
- listenerProperty.setAttachedstate(true);
- listenerProperty.setMethodargs(listener.getEventclass() + ".class");
-
- bean.addProperty(listenerProperty);
-
- listener.addSuitableComponent(bean);
- }
- }
- }
- } catch (ClassNotFoundException e) {
- throw new BuildException(e);
- }
- }
-
- for (Iterator iter = this.iterator(); iter.hasNext();) {
- ComponentBean component = (ComponentBean) iter.next();
- component.checkProperties();
- }
-
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.config.LoaderHolder#getLoader()
- */
- public ClassLoader getLoader() {
- return _loader;
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.config.LoaderHolder#setLoader(java.lang.ClassLoader)
- */
- public void setLoader(ClassLoader loader) {
- _loader = loader;
- }
-
- public Logger getLog() {
- return _log;
- }
-
- public void addComponent(ComponentBean component) {
- this.components.add(component);
- component.setParent(this);
- }
-
- public void addRenderer(RendererBean renderer) {
- this.renderers.add(renderer);
- renderer.setParent(this);
- }
-
- public void addListener(ListenerBean listener) {
- this.listeners.add(listener);
- listener.setParent(this);
- }
-
- /* (non-Javadoc)
- * @see java.util.List#clear()
- */
- public void clear() {
- components.clear();
- renderers.clear();
- }
-
- /* (non-Javadoc)
- * @see java.util.List#contains(java.lang.Object)
- */
- public boolean contains(Object o) {
- return components.contains(o);
- }
-
- /* (non-Javadoc)
- * @see java.util.List#get(int)
- */
- public ComponentBean get(int index) {
- return components.get(index);
- }
-
- /* (non-Javadoc)
- * @see java.util.List#indexOf(java.lang.Object)
- */
- public int indexOf(ComponentBean o) {
- return components.indexOf(o);
- }
-
- /* (non-Javadoc)
- * @see java.util.List#isEmpty()
- */
- public boolean isEmpty() {
- return components.isEmpty();
- }
-
- /* (non-Javadoc)
- * @see java.util.List#iterator()
- */
- public Iterator iterator() {
- return components.iterator();
- }
-
- /* (non-Javadoc)
- * @see java.util.List#listIterator()
- */
- public List<ComponentBean> getComponents() {
- return components;
- }
-
- public List<ListenerBean> getListeners() {
- return listeners;
- }
-
- /**
- * @return the renderers
- */
- public List<RendererBean> getRenderers() {
- return this.renderers;
- }
-
- /* (non-Javadoc)
- * @see java.util.List#remove(int)
- */
- public ComponentBean remove(int index) {
- return components.remove(index);
- }
-
- /* (non-Javadoc)
- * @see java.util.List#remove(java.lang.Object)
- */
- public boolean remove(ComponentBean o) {
- return components.remove(o);
- }
-
- /* (non-Javadoc)
- * @see java.util.List#size()
- */
- public int size() {
- return components.size();
- }
-}
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.config;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.ConfigurationException;
+
+import org.ajax4jsf.builder.generator.Logger;
+import org.apache.commons.digester.Digester;
+import org.apache.commons.digester.ExtendedBaseRules;
+import org.apache.tools.ant.BuildException;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.ext.EntityResolver2;
+
+/**
+ * Parse builder config file for use with component creation.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
+ * @version $Revision: 1.1.2.10 $ $Date: 2007/02/20 20:57:58 $
+ *
+ */
+public class BuilderConfig implements LoaderHolder {
+
+
+ /**
+ * Resource path to config file schemas and entities
+ */
+ public static final String COMPONENT_SCHEMA_BASE = "/META-INF/schema/";
+ /**
+ * Resource path to config file schemas and entities
+ */
+ public static final String ENTITIES_FOLDER = "entities";
+ /**
+ * default URI to dtd in classpath
+ */
+ private static final String COMPONENT_CONFIG_DTD_URI = COMPONENT_SCHEMA_BASE+"component-config.dtd";
+ /**
+ * root element of configuration file
+ */
+ private static final String GENERATOR_CONFIG_ROOT_ELEMENT = "components";
+ /**
+ * PUBLIC Id of configuration schema
+ */
+ private static final String GENERATOR_CONFIG_PUBLIC_ID = "-//AJAX4JSF//CDK Generator config/EN";
+ /**
+ * components described in this configuration
+ */
+ private List<ComponentBean> components = new ArrayList<ComponentBean>();
+
+ /**
+ * validators described in this configuration
+ */
+ private List<ValidatorBean> validators = new ArrayList<ValidatorBean>();
+
+ /**
+ * components described in this configuration
+ */
+ private List<ConverterBean> converters = new ArrayList<ConverterBean>();
+
+ /**
+ * renderers described in this configuration
+ */
+ private List<RendererBean> renderers = new ArrayList<RendererBean>();
+
+ private List<ListenerBean> listeners = new ArrayList<ListenerBean>();
+
+ private ClassLoader _loader;
+
+ private Logger _log;
+
+ /**
+ * @param project - current ant project
+ */
+ public BuilderConfig(ClassLoader loader, Logger log) {
+ _loader = loader;
+ _log = log;
+ }
+
+ /**
+ * Parsing builder configuration file
+ * @param configFile
+ * @throws ParsingException
+ */
+ public void parseConfig(final File configFile) throws ParsingException {
+ getLog().info(" Parse config file "+configFile.toString());
+ Digester digester = new Digester();
+ digester.setRules( new ExtendedBaseRules() );
+ digester.setValidating(false);
+ digester.setNamespaceAware(false);
+// try {
+ //URL dtd = this.getClass().getClassLoader().getResource(COMPONENT_CONFIG_DTD_URI);
+ //new URL("resource:/com/exadel/vcp/builder/config/component-config.dtd");
+ getLog().debug("Register config DTD as URI "+COMPONENT_CONFIG_DTD_URI);
+ digester.register(GENERATOR_CONFIG_PUBLIC_ID, COMPONENT_CONFIG_DTD_URI);
+// } catch (MalformedURLException e) {
+// throw new ParsingException("Malformed URL for internal DTD reference",e);
+// }
+
+ // setup custom entity resolver for handle file-resource path's
+ // resolve DTD even it not pointed in file, and, for entities - resolve it in
+ // classpath if entity registered in DTD witn path /META-INF/schema
+ digester.setEntityResolver(new EntityResolver2() {
+
+ /* (non-Javadoc)
+ * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
+ */
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+ getLog().debug("Request for entity with systemId "+systemId+" and publicId "+publicId);
+ if (GENERATOR_CONFIG_PUBLIC_ID.equals(publicId)) {
+ return getDTDSource();
+ } else if(null != publicId && null != systemId && systemId.contains(ENTITIES_FOLDER)){
+ int base = systemId.indexOf(ENTITIES_FOLDER);
+ String entity = COMPONENT_SCHEMA_BASE+systemId.substring(base);
+ getLog().debug("attempt to load entity from classpath "+entity);
+ InputStream entityStream = BuilderConfig.class
+ .getResourceAsStream(entity);
+ if (null != entityStream) {
+ return new InputSource(entityStream);
+ }
+ }
+ return null;
+ }
+
+ public InputSource getExternalSubset(String name, String baseURI) throws SAXException, IOException {
+ getLog().debug("Request for ExternalSubset with name "+name+" and baseURI "+baseURI);
+ if (GENERATOR_CONFIG_ROOT_ELEMENT.equals(name)) {
+ return getDTDSource();
+ }
+ return null;
+ }
+
+ public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) throws SAXException, IOException {
+ getLog().debug("Request for extended entity with systemId "+systemId+" and publicId "+publicId);
+ getLog().debug("additional parameters with name "+name+" and baseURI "+baseURI);
+ if ("[dtd]".equals(name) && GENERATOR_CONFIG_PUBLIC_ID.equals(publicId)) {
+ return getDTDSource();
+ }
+ else if (null==name || (!name.startsWith("[") && !name.startsWith("&"))) {
+ return resolveEntity(publicId,systemId);
+ }
+ return null;
+ }
+
+ /**
+ * Resolve config DTD from classpath
+ * @return source of config file DTD
+ */
+ private InputSource getDTDSource() {
+ return new InputSource(BuilderConfig.class.getResourceAsStream(COMPONENT_CONFIG_DTD_URI));
+ }
+
+ });
+
+ // Parsing rules.
+
+ // Components
+ String path = "components/component";
+ digester.addObjectCreate(path, ComponentBean.class);
+ digester.addBeanPropertySetter(path+"/name");
+ digester.addBeanPropertySetter(path+"/family");
+ digester.addBeanPropertySetter(path+"/classname");
+ digester.addBeanPropertySetter(path+"/superclass");
+ digester.addBeanPropertySetter(path+"/description");
+ digester.addBeanPropertySetter(path+"/displayname");
+ digester.addBeanPropertySetter(path+"/icon");
+ // TODO - for superclass, populate from description in config file, if exist
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "addComponent");
+ path = "components/renderer";
+ digester.addObjectCreate(path, RendererBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "addRenderer");
+ path = "components/component/renderer";
+ digester.addObjectCreate(path, RendererBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "setRenderer");
+
+ path = "components/component/facet";
+ digester.addObjectCreate(path, JsfBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "addFacet");
+ path = "components/component/event";
+ digester.addObjectCreate(path, EventBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "addEvent");
+
+ // Validators
+
+ path = "components/validator";
+ digester.addObjectCreate(path, ValidatorBean.class);
+ digester.addBeanPropertySetter(path+"/id");
+ digester.addBeanPropertySetter(path+"/classname");
+ digester.addBeanPropertySetter(path+"/superclass");
+ digester.addBeanPropertySetter(path+"/description");
+ digester.addBeanPropertySetter(path+"/displayname");
+ digester.addBeanPropertySetter(path+"/icon");
+ // TODO - for superclass, populate from description in config file, if exist
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "addValidator");
+
+ // Converters
+
+ path = "components/converter";
+ digester.addObjectCreate(path, ConverterBean.class);
+ digester.addBeanPropertySetter(path+"/id");
+ digester.addBeanPropertySetter(path+"/classname");
+ digester.addBeanPropertySetter(path+"/superclass");
+ digester.addBeanPropertySetter(path+"/description");
+ digester.addBeanPropertySetter(path+"/displayname");
+ digester.addBeanPropertySetter(path+"/icon");
+ digester.addBeanPropertySetter(path+"/forclass");
+ // TODO - for superclass, populate from description in config file, if exist
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "addConverter");
+
+ // - Tags & Tag handlers
+
+ path = "components/component/tag";
+ digester.addObjectCreate(path, TagBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "setTag");
+
+ path = "components/validator/tag";
+ digester.addObjectCreate(path, TagBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "setTag");
+
+ path = "components/converter/tag";
+ digester.addObjectCreate(path, TagBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "setTag");
+
+ path = "components/component/tag/test";
+ digester.addObjectCreate(path, TestClassHolder.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "setTest");
+
+ path = "components/component/test";
+ digester.addObjectCreate(path, TestClassHolder.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "setTest");
+
+ path = "components/component/taghandler";
+ digester.addObjectCreate(path, TagHandlerBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "setTaghandler");
+/*
+ path = "components/component/taghandler/test";
+ digester.addObjectCreate(path, TestClassHolder.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "setTest");
+*/
+
+ // Properties
+
+ path = "components/component/property";
+ digester.addObjectCreate(path, PropertyBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "addProperty");
+
+ path = "components/validator/property";
+ digester.addObjectCreate(path, PropertyBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "addProperty");
+
+ path = "components/converter/property";
+ digester.addObjectCreate(path, PropertyBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "addProperty");
+
+ path = "*/properties/property";
+ digester.addObjectCreate(path, PropertyBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "addProperty");
+
+ // Listeners
+
+ path = "components/listener";
+ digester.addObjectCreate(path, ListenerBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "addListener");
+ path = "components/listener/tag";
+ digester.addObjectCreate(path, TagBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "setTag");
+ path = "components/listener/taghandler";
+ digester.addObjectCreate(path, TagHandlerBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "setTaghandler");
+ path = "components/listener/property";
+ digester.addObjectCreate(path, PropertyBean.class);
+ digester.addBeanPropertySetter(path+"/?");
+ digester.addSetProperties(path);
+ digester.addSetNext(path, "addProperty");
+
+
+
+
+
+ // Set this config as root.
+ digester.push(this);
+ try {
+ digester.parse(configFile.toString());
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ throw new ParsingException("I/O error on parsing config file ",e);
+ } catch (SAXException e) {
+ // TODO Auto-generated catch block
+ throw new ParsingException("SAX Parsing error in config file ",e);
+ }
+// checkComopnentProperties();
+// return this;
+ }
+
+ /**
+ * Check all components for existing and default properties.
+ * @param classpath - classpath to find user components, renderers, tags
+ * @throws ConfigurationException
+ */
+ public void checkComopnentProperties() throws ParsingException {
+// ClassLoader loader = getProject().createClassLoader(classpath);
+// if(null == loader) {
+// loader = this.getClass().getClassLoader();
+// }
+// setLoader(loader);
+
+ for (ListenerBean listener : getListeners()) {
+ try {
+ Class<?> listenerClass = Class.forName(listener.getComponentclass(), false, getLoader());
+ for (ComponentBean bean : getComponents()) {
+ if (bean.getSuperclass() != null) {
+ Class<?> componentSClass = Class.forName(bean.getSuperclass(), false, getLoader());
+
+ if (listenerClass.isAssignableFrom(componentSClass)) {
+
+ PropertyBean listenerProperty = new PropertyBean();
+ listenerProperty.setClassname("javax.faces.el.MethodBinding");
+ listenerProperty.setEl(true);
+ listenerProperty.setElonly(true);
+ listenerProperty.setName(listener.getName());
+ listenerProperty.setAttachedstate(true);
+ listenerProperty.setMethodargs(listener.getEventclass() + ".class");
+
+ bean.addProperty(listenerProperty);
+
+ listener.addSuitableComponent(bean);
+ }
+ }
+ }
+ } catch (ClassNotFoundException e) {
+ throw new BuildException(e);
+ }
+ }
+
+ for (Iterator iter = this.getComponents().iterator(); iter.hasNext();) {
+ ComponentBaseBean component = (ComponentBaseBean) iter.next();
+ component.checkProperties();
+ }
+
+ for (Iterator iter = this.getValidators().iterator(); iter.hasNext();) {
+ ComponentBaseBean component = (ComponentBaseBean) iter.next();
+ component.checkProperties();
+ }
+
+ for (Iterator iter = this.getConverters().iterator(); iter.hasNext();) {
+ ComponentBaseBean component = (ComponentBaseBean) iter.next();
+ component.checkProperties();
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.config.LoaderHolder#getLoader()
+ */
+ public ClassLoader getLoader() {
+ return _loader;
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.config.LoaderHolder#setLoader(java.lang.ClassLoader)
+ */
+ public void setLoader(ClassLoader loader) {
+ _loader = loader;
+ }
+
+ public Logger getLog() {
+ return _log;
+ }
+
+ public void addComponent(ComponentBean component) {
+ this.components.add(component);
+ component.setParent(this);
+ }
+
+ public void addValidator(ValidatorBean validator) {
+ this.validators.add(validator);
+ validator.setParent(this);
+ }
+
+ public void addConverter(ConverterBean converter) {
+ this.converters.add(converter);
+ converter.setParent(this);
+ }
+
+ public void addRenderer(RendererBean renderer) {
+ this.renderers.add(renderer);
+ renderer.setParent(this);
+ }
+
+ public void addListener(ListenerBean listener) {
+ this.listeners.add(listener);
+ listener.setParent(this);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#clear()
+ */
+ public void clear() {
+ components.clear();
+ renderers.clear();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#contains(java.lang.Object)
+ */
+ public boolean contains(Object o) {
+ return components.contains(o);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#get(int)
+ */
+ public ComponentBaseBean get(int index) {
+ return components.get(index);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#indexOf(java.lang.Object)
+ */
+ public int indexOf(ComponentBaseBean o) {
+ return components.indexOf(o);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#isEmpty()
+ */
+ public boolean isEmpty() {
+ return components.isEmpty();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#listIterator()
+ */
+ public List<ComponentBean> getComponents() {
+ return components;
+ }
+
+ public List<ConverterBean> getConverters() {
+ return converters;
+ }
+
+ public List<ValidatorBean> getValidators() {
+ return validators;
+ }
+
+ public List<ListenerBean> getListeners() {
+ return listeners;
+ }
+
+ /**
+ * @return the renderers
+ */
+ public List<RendererBean> getRenderers() {
+ return this.renderers;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#remove(int)
+ */
+ public ComponentBaseBean remove(int index) {
+ return components.remove(index);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#remove(java.lang.Object)
+ */
+ public boolean remove(ComponentBaseBean o) {
+ return components.remove(o);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.List#size()
+ */
+ public int size() {
+ return components.size();
+ }
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBaseBean.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBaseBean.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBaseBean.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1,278 @@
+package org.ajax4jsf.builder.config;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.ConfigurationException;
+
+import org.apache.commons.beanutils.PropertyUtils;
+
+public class ComponentBaseBean extends JsfBean {
+
+ private static final String[] ignorableComponentProperties = {
+ "class",
+ "attributes",
+ "childCount",
+ "children",
+ "facets",
+ "facetsAndChildren",
+ "family",
+ "parent",
+ "rendererType",
+ "rendersChildren",
+ "submittedValue",
+ "transient"};
+ private static final String[] enabledTagProperties = {
+ "binding"
+ };
+ private static final String[] attachedStateProperties = {
+ "javax.faces.component.StateHolder",
+ "java.util.List",
+ "javax.faces.el.MethodBinding",
+ "javax.faces.el.ValueBinding",
+ "javax.faces.convert.Converter"
+ };
+ /**
+ * JSP ( facelets ? ) tag description for component
+ */
+ private TagBean _tag;
+ private TagHandlerBean _taghandler;
+ /**
+ * Descriptions of component JavaBean properties
+ */
+ private Map<String,PropertyBean> properties = new HashMap<String,PropertyBean>();
+ /**
+ * Flag for generate component instance class
+ */
+ private boolean generate = true;
+
+ /**
+ * @return Returns the tag.
+ */
+ public TagBean getTag() {
+ return _tag;
+ }
+
+ /**
+ * @param tag The tag to set.
+ */
+ public void setTag(TagBean tag) {
+ _tag = tag;
+ tag.setParent(this);
+ }
+
+ /**
+ * @return Returns the generate.
+ */
+ public boolean isGenerate() {
+ return this.generate;
+ }
+
+ /**
+ * @param generate The generate to set.
+ */
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
+
+ /**
+ * @return Returns the tagSupport.
+ */
+ public TagHandlerBean getTaghandler() {
+ return this._taghandler;
+ }
+
+ /**
+ * @param tagSupport The tagSupport to set.
+ */
+ public void setTaghandler(TagHandlerBean tagSupport) {
+ this._taghandler = tagSupport;
+ }
+
+ /**
+ * @return Returns the properties.
+ */
+ public Collection<PropertyBean> getProperties() {
+ return properties.values();
+ }
+
+ /**
+ * @param name
+ * @return true if component have property with given name
+ */
+ public boolean containProperty(String name) {
+ return properties.containsKey(name);
+ }
+
+ /**
+ * Append property to component. If property with name exist, replace it
+ * @param property
+ */
+ public void addProperty(PropertyBean property) {
+ this.properties.put(property.getName(),property);
+ property.setParent(this);
+ }
+
+ /**
+ * Subclasses should extend this method to provide specifc checks
+ *
+ * Check existing and default properties
+ * For properties filled from configuration, attempt to set additional parameters.
+ * If base class have any bean properties, append it to configured
+ * @throws ConfigurationException
+ */
+ public void checkProperties() throws ParsingException {
+ try {
+ getLog().debug("Parse properties for Component "+getName()+" with superclass "+getSuperclass());
+ if (getSuperclass() != null)
+ {
+ Class superClass = getLoader().loadClass(getSuperclass());
+
+ Class superSuperClass = superClass;
+
+ while (null != superSuperClass ) {
+ Class[] interfaces = superSuperClass.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++) {
+ Class interfaceClass = interfaces[i];
+ checkPropertiesForClass(interfaceClass);
+ }
+ superSuperClass = superSuperClass.getSuperclass();
+ }
+ checkPropertiesForClass(superClass);
+ }
+ } catch (ClassNotFoundException e) {
+ getLog().error("superclass not found for component "+getName(), e);
+ }
+ if (null != getTag()) {
+ try {
+ Class superClass = getLoader().loadClass(getTag().getSuperclass());
+ PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(superClass);
+ // for all properties, add it to component. If property have not abstract getter/setter ,
+ // add it with exist = true . If property in list of hidden names, set hidden = true.
+ for (int i = 0; i < properties.length; i++) {
+ PropertyDescriptor descriptor = properties[i];
+ Method writeMethod = descriptor.getWriteMethod();
+ if(containProperty(descriptor.getName())){
+ if (null != writeMethod && !Modifier.isAbstract(writeMethod.getModifiers()) && Modifier.isPublic(writeMethod.getModifiers()) ) {
+ ((PropertyBean) this.properties.get(descriptor
+ .getName())).setExistintag(true);
+ }
+ } else if (null != writeMethod && Modifier.isPublic(writeMethod.getModifiers())) {
+ if (Arrays.asList(enabledTagProperties).contains(
+ descriptor.getName())) {
+ Class type = descriptor.getPropertyType();
+ getLog().debug("Register tag property "
+ + descriptor.getName() + " with type name "
+ + type.getCanonicalName() );
+ PropertyBean property = new PropertyBean();
+ property.setName(descriptor.getName());
+ property.setDescription(descriptor
+ .getShortDescription());
+ property
+ .setDisplayname(descriptor.getDisplayName());
+ property.setClassname(descriptor.getPropertyType()
+ .getCanonicalName());
+ property.setExist(true);
+ if (!Modifier
+ .isAbstract(writeMethod.getModifiers())) {
+ property.setExistintag(true);
+ }
+ addProperty(property);
+ }
+ }
+ }
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ getLog().error("superclass not found for tag "+getTag().getName(), e);
+ }
+
+ }
+ }
+
+ /**
+ * @param superClass
+ */
+ private void checkPropertiesForClass(Class superClass) {
+ getLog().debug("Check properties for class "+superClass.getName());
+ // get all property descriptors
+ PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(superClass);
+ // for all properties, add it to component. If property have not abstract getter/setter ,
+ // add it with exist = true . If property in list of hidden names, set hidden = true.
+ PropertyBean property;
+ for (int i = 0; i < properties.length; i++) {
+ PropertyDescriptor descriptor = properties[i];
+ if(!containProperty(descriptor.getName())){
+ if(isIgnorableProperty(superClass, descriptor.getName())) {
+ continue;
+ }
+ Class type = descriptor.getPropertyType();
+ getLog().debug("Register property "+descriptor.getName()+" with type name "+type.getCanonicalName());
+ property = new PropertyBean();
+ property.setName(descriptor.getName());
+ property.setDescription(descriptor.getShortDescription());
+ property.setDisplayname(descriptor.getDisplayName());
+ property.setClassname(descriptor.getPropertyType().getCanonicalName());
+ property.setExist(true);
+ addProperty(property);
+ } else {
+ // Load and check property.
+ getLog().debug("Check property "+descriptor.getName());
+ property = (PropertyBean) this.properties.get(descriptor.getName());
+ if(property.getClassname() == null) {
+ property.setClassname(descriptor.getPropertyType().getCanonicalName());
+ } else {
+ if(!property.getClassname().equals(descriptor.getPropertyType().getCanonicalName())){
+ getLog().error("Class "+property.getClassname()+" for property "+property.getName()+" not equals with real bean property type: "+descriptor.getPropertyType().getCanonicalName());
+ }
+ }
+ if (property.getDescription() == null) {
+ property.setDescription(descriptor.getShortDescription());
+ }
+ if(property.getDisplayname() == null){
+ property.setDisplayname(descriptor.getDisplayName());
+ }
+ property.setExist(true);
+ }
+ Method getter = descriptor.getReadMethod();
+ Method setter = descriptor.getWriteMethod();
+ // Abstract methods
+ if(null != setter && null != getter ){
+ if( Modifier.isAbstract(getter.getModifiers()) && Modifier.isAbstract(setter.getModifiers())&& Modifier.isPublic(setter.getModifiers()) ){
+ getLog().debug("Detect as abstract property "+descriptor.getName());
+ property.setExist(false);
+ }
+ }
+ if(null == setter || (! Modifier.isPublic(setter.getModifiers())) ){
+ getLog().debug("Detect as hidden property "+descriptor.getName());
+ property.setHidden(true);
+ }
+ if (isAttachedProperty(property)) {
+ property.setAttachedstate(true);
+ }
+ if (property.isInstanceof("javax.faces.el.MethodBinding") || property.isInstanceof("javax.faces.el.ValueBinding")) {
+ property.setElonly(true);
+ }
+
+ }
+ }
+
+ private boolean isIgnorableProperty(Class base, String name) {
+ return Arrays.asList(ignorableComponentProperties).contains(name);
+ }
+
+ private boolean isAttachedProperty(PropertyBean prop) {
+ for (int i = 0; i < attachedStateProperties.length; i++) {
+ String clazz = attachedStateProperties[i];
+ if(prop.isInstanceof(clazz)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBean.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBean.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBean.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,412 +1,154 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.config;
-
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.naming.ConfigurationException;
-
-import org.apache.commons.beanutils.PropertyUtils;
-
-/**
- * JavaBean to hold properties of component configuration.
- * At parsing configuration time, all propertiec can be set as attributes or
- * child elements of <component>: element/.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.8 $ $Date: 2007/03/01 17:16:00 $
- *
- */
-public class ComponentBean extends JsfBean {
-
- private static final String[] ignorableComponentProperties= {
- "class",
- "attributes",
- "childCount",
- "children",
- "facets",
- "facetsAndChildren",
- "family",
- "parent",
- "rendererType",
- "rendersChildren",
- "submittedValue",
- "transient"};
-
- private static final String[] enabledTagProperties= {
- "binding"
- };
-
- private static final String[] attachedStateProperties = {
- "javax.faces.component.StateHolder",
- "java.util.List",
- "javax.faces.el.MethodBinding",
- "javax.faces.el.ValueBinding",
- "javax.faces.convert.Converter"
- };
- /**
- * Component family
- */
- private String _family;
-
- /**
- * Component child facets, for faces-config.xml
- */
- private Set _facets = new HashSet();
-
- /**
- * Renderer description for this components
- */
- private RendererBean renderer;
-
- /**
- * JSP ( facelets ? ) tag description for component
- */
- private TagBean _tag;
-
-
- private TagHandlerBean _taghandler;
- /**
- * Descriptions of component JavaBean properties
- */
- private Map<String,PropertyBean> properties = new HashMap<String,PropertyBean>();
-
- /**
- * Events used by this component.
- */
- private Set<EventBean> events = new HashSet<EventBean>();
-
- /**
- * Flag for generate component instance class
- */
- private boolean generate = true;
-
- /**
- * @return Returns the facet.
- */
- public Set getFacets() {
- return _facets;
- }
-
- /**
- * @param facet The facet to set.
- */
- public void addFacet(JsfBean facet) {
- _facets.add(facet);
- }
-
- /**
- * @return Returns the family.
- */
- public String getFamily() {
- return _family;
- }
-
- /**
- * @param family The family to set.
- */
- public void setFamily(String family) {
- _family = family;
- }
-
- /**
- * @return Returns the renderer.
- */
- public RendererBean getRenderer() {
- return renderer;
- }
-
- /**
- * @return Returns the tag.
- */
- public TagBean getTag() {
- return _tag;
- }
-
- /**
- * @param tag The tag to set.
- */
- public void setTag(TagBean tag) {
- _tag = tag;
- tag.setParent(this);
- }
-
- /**
- * @param renderer The renderer to set.
- */
- public void setRenderer(RendererBean renderer) {
- this.renderer = renderer;
- renderer.setParent(this);
- }
-
- /**
- * @return Returns the generate.
- */
- public boolean isGenerate() {
- return this.generate;
- }
-
- /**
- * @param generate The generate to set.
- */
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
-
- /**
- * @return Returns the tagSupport.
- */
- public TagHandlerBean getTaghandler() {
- return this._taghandler;
- }
-
- /**
- * @param tagSupport The tagSupport to set.
- */
- public void setTaghandler(TagHandlerBean tagSupport) {
- this._taghandler = tagSupport;
- }
-
- /**
- * @return Returns the properties.
- */
- public Collection<PropertyBean> getProperties() {
- return properties.values();
- }
-
- /**
- * @param name
- * @return true if component have property with given name
- */
- public boolean containProperty( String name ){
- return properties.containsKey(name);
- }
-
- /**
- * Append property to component. If property with name exist, replace it
- * @param property
- */
- public void addProperty(PropertyBean property) {
- this.properties.put(property.getName(),property);
- property.setParent(this);
- }
-
- /**
- * @return the events
- */
- public Set<EventBean> getEvents() {
- return this.events;
- }
-
- public void addEvent(EventBean event) {
- this.events.add(event);
- event.setParent(this);
- }
-
- /**
- * Check existing and default properties for this component.
- * For properties filled from configuration, attempt to set additional parameters.
- * If base class have any bean properties, append it to configured
- * @throws ConfigurationException
- */
- public void checkProperties() throws ParsingException {
- if (null != getRenderer()) {
- getRenderer().checkProperties();
- }
- for (EventBean event : getEvents()) {
- event.checkProperties();
- }
- try {
- getLog().debug("Parse properties for Component "+getName()+" with superclass "+getSuperclass());
- Class superClass = getLoader().loadClass(getSuperclass());
- // Attempt to check component Family
- if (null == getFamily()) {
- try {
- Object componentInstance = superClass
- .newInstance();
- String family = (String) PropertyUtils.getProperty(componentInstance, "family");
- setFamily(family);
- getLog().debug("Detect family of component as "+family);
- } catch (Exception e) {
- getLog().error("Error for create instance of component "+getSuperclass()+" exception: "+e.getClass().getName()+" with message "+e.getMessage());
- throw new ParsingException("'Family' property not set for component"+getName());
- }
- }
- Class superSuperClass = superClass;
-
- while (null != superSuperClass ) {
- Class[] interfaces = superSuperClass.getInterfaces();
- for (int i = 0; i < interfaces.length; i++) {
- Class interfaceClass = interfaces[i];
- checkPropertiesForClass(interfaceClass);
- }
- superSuperClass = superSuperClass.getSuperclass();
- }
- checkPropertiesForClass(superClass);
- } catch (ClassNotFoundException e) {
- getLog().error("superclass not found for component "+getName(), e);
- }
- if (null != getTag()) {
- try {
- Class superClass = getLoader().loadClass(getTag().getSuperclass());
- PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(superClass);
- // for all properties, add it to component. If property have not abstract getter/setter ,
- // add it with exist = true . If property in list of hidden names, set hidden = true.
- for (int i = 0; i < properties.length; i++) {
- PropertyDescriptor descriptor = properties[i];
- Method writeMethod = descriptor.getWriteMethod();
- if(containProperty(descriptor.getName())){
- if (null != writeMethod && !Modifier.isAbstract(writeMethod.getModifiers()) && Modifier.isPublic(writeMethod.getModifiers()) ) {
- ((PropertyBean) this.properties.get(descriptor
- .getName())).setExistintag(true);
- }
- } else if (null != writeMethod && Modifier.isPublic(writeMethod.getModifiers())) {
- if (Arrays.asList(enabledTagProperties).contains(
- descriptor.getName())) {
- Class type = descriptor.getPropertyType();
- getLog().debug("Register tag property "
- + descriptor.getName() + " with type name "
- + type.getCanonicalName() );
- PropertyBean property = new PropertyBean();
- property.setName(descriptor.getName());
- property.setDescription(descriptor
- .getShortDescription());
- property
- .setDisplayname(descriptor.getDisplayName());
- property.setClassname(descriptor.getPropertyType()
- .getCanonicalName());
- property.setExist(true);
- if (!Modifier
- .isAbstract(writeMethod.getModifiers())) {
- property.setExistintag(true);
- }
- addProperty(property);
- }
- }
- }
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- getLog().error("superclass not found for tag "+getTag().getName(), e);
- }
-
- }
- }
-
- /**
- * @param superClass
- */
- private void checkPropertiesForClass(Class superClass) {
- getLog().debug("Check properties for class "+superClass.getName());
- // get all property descriptors
- PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(superClass);
- // for all properties, add it to component. If property have not abstract getter/setter ,
- // add it with exist = true . If property in list of hidden names, set hidden = true.
- PropertyBean property;
- for (int i = 0; i < properties.length; i++) {
- PropertyDescriptor descriptor = properties[i];
- if(!containProperty(descriptor.getName())){
- if(isIgnorableProperty(superClass, descriptor.getName())) {
- continue;
- }
- Class type = descriptor.getPropertyType();
- getLog().debug("Register property "+descriptor.getName()+" with type name "+type.getCanonicalName());
- property = new PropertyBean();
- property.setName(descriptor.getName());
- property.setDescription(descriptor.getShortDescription());
- property.setDisplayname(descriptor.getDisplayName());
- property.setClassname(descriptor.getPropertyType().getCanonicalName());
- property.setExist(true);
- addProperty(property);
- } else {
- // Load and check property.
- getLog().debug("Check property "+descriptor.getName());
- property = (PropertyBean) this.properties.get(descriptor.getName());
- if(property.getClassname() == null) {
- property.setClassname(descriptor.getPropertyType().getCanonicalName());
- } else {
- if(!property.getClassname().equals(descriptor.getPropertyType().getCanonicalName())){
- getLog().error("Class "+property.getClassname()+" for property "+property.getName()+" not equals with real bean property type: "+descriptor.getPropertyType().getCanonicalName());
- }
- }
- if (property.getDescription() == null) {
- property.setDescription(descriptor.getShortDescription());
- }
- if(property.getDisplayname() == null){
- property.setDisplayname(descriptor.getDisplayName());
- }
- property.setExist(true);
- }
- Method getter = descriptor.getReadMethod();
- Method setter = descriptor.getWriteMethod();
- // Abstract methods
- if(null != setter && null != getter ){
- if( Modifier.isAbstract(getter.getModifiers()) && Modifier.isAbstract(setter.getModifiers())&& Modifier.isPublic(setter.getModifiers()) ){
- getLog().debug("Detect as abstract property "+descriptor.getName());
- property.setExist(false);
- }
- }
- if(null == setter || (! Modifier.isPublic(setter.getModifiers())) ){
- getLog().debug("Detect as hidden property "+descriptor.getName());
- property.setHidden(true);
- }
- if (isAttachedProperty(property)) {
- property.setAttachedstate(true);
- }
- if (property.isInstanceof("javax.faces.el.MethodBinding") || property.isInstanceof("javax.faces.el.ValueBinding")) {
- property.setElonly(true);
- }
-
- }
- }
-
- private boolean isIgnorableProperty(Class base,String name) {
- return Arrays.asList(ignorableComponentProperties).contains(name);
- }
-
- private boolean isAttachedProperty(PropertyBean prop) {
- for (int i = 0; i < attachedStateProperties.length; i++) {
- String clazz = attachedStateProperties[i];
- if(prop.isInstanceof(clazz)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public TestClassHolder getTest() {
- return super.getTest();
- }
-
- @Override
- public void setTest(TestClassHolder test) {
- super.setTest(test);
- test.setClassname(getClassname() + "ComponentTest");
- }
-}
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.config;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.beanutils.PropertyUtils;
+
+
+
+/**
+ * JavaBean to hold properties of component configuration.
+ * At parsing configuration time, all propertiec can be set as attributes or
+ * child elements of <component>: element/.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.8 $ $Date: 2007/03/01 17:16:00 $
+ *
+ */
+public class ComponentBean extends ComponentBaseBean {
+
+ /**
+ * Component family
+ */
+ private String _family;
+
+ /**
+ * Component child facets, for faces-config.xml
+ */
+ private Set _facets = new HashSet();
+
+ /**
+ * Renderer description for this components
+ */
+ private RendererBean renderer;
+
+ /**
+ * Events used by this component.
+ */
+ private Set<EventBean> events = new HashSet<EventBean>();
+
+ /**
+ * @return Returns the facet.
+ */
+ public Set getFacets() {
+ return _facets;
+ }
+
+ /**
+ * @param facet The facet to set.
+ */
+ public void addFacet(JsfBean facet) {
+ _facets.add(facet);
+ }
+
+ /**
+ * @return Returns the family.
+ */
+ public String getFamily() {
+ return _family;
+ }
+
+ /**
+ * @param family The family to set.
+ */
+ public void setFamily(String family) {
+ _family = family;
+ }
+
+ /**
+ * @return Returns the renderer.
+ */
+ public RendererBean getRenderer() {
+ return renderer;
+ }
+
+ /**
+ * @param renderer The renderer to set.
+ */
+ public void setRenderer(RendererBean renderer) {
+ this.renderer = renderer;
+ renderer.setParent(this);
+ }
+
+ /**
+ * @return the events
+ */
+ public Set<EventBean> getEvents() {
+ return this.events;
+ }
+
+ public void addEvent(EventBean event) {
+ this.events.add(event);
+ event.setParent(this);
+ }
+
+ @Override
+ public TestClassHolder getTest() {
+ return super.getTest();
+ }
+
+ @Override
+ public void setTest(TestClassHolder test) {
+ super.setTest(test);
+ test.setClassname(getClassname() + "ComponentTest");
+ }
+
+ @Override
+ /**
+ * Component checks
+ */
+ public void checkProperties() throws ParsingException {
+ super.checkProperties();
+ if (null != getRenderer()) {
+ getRenderer().checkProperties();
+ }
+ for (EventBean event : getEvents()) {
+ event.checkProperties();
+ }
+ // Attempt to check component Family
+ if (null == getFamily()) {
+ try {
+ Class superClass = getLoader().loadClass(getSuperclass());
+ Object componentInstance = superClass
+ .newInstance();
+ String family = (String) PropertyUtils.getProperty(componentInstance, "family");
+ setFamily(family);
+ getLog().debug("Detect family of component as "+family);
+ } catch (Exception e) {
+ getLog().error("Error for create instance of component "+getSuperclass()+" exception: "+e.getClass().getName()+" with message "+e.getMessage());
+ throw new ParsingException("'Family' property not set for component"+getName());
+ }
+ }
+ }
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ConverterBean.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ConverterBean.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ConverterBean.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1,26 @@
+package org.ajax4jsf.builder.config;
+
+public class ConverterBean extends ComponentBaseBean {
+
+ private String forclass;
+
+ // Map the id onto name
+
+ public String getId() {
+ return super.getName();
+ }
+
+ public void setId(String id)
+ {
+ super.setName(id);
+ }
+
+ public String getForclass() {
+ return forclass;
+ }
+
+ public void setForclass(String forclass) {
+ this.forclass = forclass;
+ }
+
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ValidatorBean.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ValidatorBean.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ValidatorBean.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1,17 @@
+package org.ajax4jsf.builder.config;
+
+public class ValidatorBean extends ComponentBaseBean {
+
+
+ // Map the id onto name
+
+ public String getId() {
+ return super.getName();
+ }
+
+ public void setId(String id)
+ {
+ super.setName(id);
+ }
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/BlankRendererGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/BlankRendererGenerator.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/BlankRendererGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,157 +1,157 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-
-
-/**
-* Class implement functionality for generate base renderers java files,
-* for manual extention. If renderer property override in config file set to true,
-* override existing renderers files.
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
- * use in ant build.xml :
- * <jsfgenerator ... >
- * ....
- * <renderers ... />
- * ....
- * </jsfgenerator>
- * attributes:
- * package - optional Java package name for override from configuration, used for create set of differern render-kits in one task
-* {@see com.exadel.vcp.builder.ant.InnerGenerator}
- * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/20 20:58:00 $
- *
- */
-public class BlankRendererGenerator extends InnerGenerator {
-
- private static final String RENDERER_TEMPLATE_NAME = "renderer.vm";
-
- /**
- * Optional package name for override from config.
- */
- private String _package = null;
-
- /**
- * @return Returns the package.
- */
- public String getPackage() {
- return _package;
- }
- /**
- * @param package1 The package to set.
- */
- public void setPackage(String package1) {
- _package = package1;
- }
-
- /**
- * @param task
- */
- public BlankRendererGenerator(JSFGeneratorConfiguration task, Logger log) {
- super(task,log);
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
- */
- public void createFiles(BuilderConfig config) throws GeneratorException {
- VelocityContext context = new VelocityContext();
- Template template = getTemplate();
-// context.put("templateName",COMPONENT_FILE_TEMPLATE);
- // Put common properties
- for (Iterator iter = config.iterator(); iter.hasNext();) {
- ComponentBean component = (ComponentBean) iter.next();
- if (null != component.getRenderer() && component.getRenderer().isGenerate()) {
- context.put("component", component);
- context.put("renderer", component.getRenderer());
- if (null == getPackage()) {
- context.put("package", component.getRenderer()
- .getPackageName());
- } else {
- context.put("package", getPackage());
- }
- Set<String> importClasses = new HashSet<String>();
-// for (Iterator it = component.getProperties().iterator(); it
-// .hasNext();) {
-// PropertyBean property = (PropertyBean) it.next();
-// // For non-primitive types, add import declaration.
-// if (!property.isSimpleType() && !property.isExist()) {
-// importClasses.add(property.getClassname());
-// }
-// }
- importClasses.add(component.getClassname());
- importClasses.add(component.getRenderer().getSuperclass());
- context.put("imports", importClasses);
- String resultPath ;
- if (null == getPackage()) {
- resultPath = component.getRenderer().getClassname().replace('.', '/') + ".java";
- } else {
- resultPath = getPackage().replace('.', '/') +"/"+component.getRenderer().getSimpleClassName()+ ".java";
- }
-
- File javaFile = new File(getDestDir(), resultPath);
- File javaDir = javaFile.getParentFile();
- if (!javaDir.exists()) {
- javaDir.mkdirs();
- }
- try {
- if (javaFile.exists()) {
- if (component.getRenderer().isOverride()) {
- javaFile.delete();
- } else {
- continue;
- }
- }
- Writer out = new BufferedWriter(new FileWriter(javaFile));
- template.merge(context, out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw new GeneratorException(
- "Error create new Renderer Java file ", e);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
- */
- protected String getDefaultTemplateName() {
- // TODO Auto-generated method stub
- return RENDERER_TEMPLATE_NAME;
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ComponentBean;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+
+/**
+* Class implement functionality for generate base renderers java files,
+* for manual extention. If renderer property override in config file set to true,
+* override existing renderers files.
+ * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * use in ant build.xml :
+ * <jsfgenerator ... >
+ * ....
+ * <renderers ... />
+ * ....
+ * </jsfgenerator>
+ * attributes:
+ * package - optional Java package name for override from configuration, used for create set of differern render-kits in one task
+* {@see com.exadel.vcp.builder.ant.InnerGenerator}
+ * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/20 20:58:00 $
+ *
+ */
+public class BlankRendererGenerator extends InnerGenerator {
+
+ private static final String RENDERER_TEMPLATE_NAME = "renderer.vm";
+
+ /**
+ * Optional package name for override from config.
+ */
+ private String _package = null;
+
+ /**
+ * @return Returns the package.
+ */
+ public String getPackage() {
+ return _package;
+ }
+ /**
+ * @param package1 The package to set.
+ */
+ public void setPackage(String package1) {
+ _package = package1;
+ }
+
+ /**
+ * @param task
+ */
+ public BlankRendererGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task,log);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
+ */
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+// context.put("templateName",COMPONENT_FILE_TEMPLATE);
+ // Put common properties
+ for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
+ ComponentBean component = (ComponentBean) iter.next();
+ if (null != component.getRenderer() && component.getRenderer().isGenerate()) {
+ context.put("component", component);
+ context.put("renderer", component.getRenderer());
+ if (null == getPackage()) {
+ context.put("package", component.getRenderer()
+ .getPackageName());
+ } else {
+ context.put("package", getPackage());
+ }
+ Set<String> importClasses = new HashSet<String>();
+// for (Iterator it = component.getProperties().iterator(); it
+// .hasNext();) {
+// PropertyBean property = (PropertyBean) it.next();
+// // For non-primitive types, add import declaration.
+// if (!property.isSimpleType() && !property.isExist()) {
+// importClasses.add(property.getClassname());
+// }
+// }
+ importClasses.add(component.getClassname());
+ importClasses.add(component.getRenderer().getSuperclass());
+ context.put("imports", importClasses);
+ String resultPath ;
+ if (null == getPackage()) {
+ resultPath = component.getRenderer().getClassname().replace('.', '/') + ".java";
+ } else {
+ resultPath = getPackage().replace('.', '/') +"/"+component.getRenderer().getSimpleClassName()+ ".java";
+ }
+
+ File javaFile = new File(getDestDir(), resultPath);
+ File javaDir = javaFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (javaFile.exists()) {
+ if (component.getRenderer().isOverride()) {
+ javaFile.delete();
+ } else {
+ continue;
+ }
+ }
+ Writer out = new BufferedWriter(new FileWriter(javaFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error create new Renderer Java file ", e);
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
+ */
+ protected String getDefaultTemplateName() {
+ // TODO Auto-generated method stub
+ return RENDERER_TEMPLATE_NAME;
+ }
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentGenerator.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,123 +1,123 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-
-
-/**
- * Class implement functionality for generate component java files
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
- * use in ant build.xml :
- * <jsfgenerator ... >
- * ....
- * <components ... />
- * ....
- * </jsfgenerator>
- * attributes:
- * {@see com.exadel.vcp.builder.ant.InnerGenerator}
- * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/20 20:58:00 $
- *
- */
-public class ComponentGenerator extends InnerGenerator {
-
- private static final String COMPONENT_FILE_TEMPLATE = "component.vm";
- /**
- * @param task
- */
- public ComponentGenerator(JSFGeneratorConfiguration task, Logger log) {
- super(task,log);
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
- */
- public void createFiles(BuilderConfig config) throws GeneratorException {
- VelocityContext context = new VelocityContext();
- Template template = getTemplate();
- context.put("generator",this);
- // Put common properties
- for (Iterator iter = config.iterator(); iter.hasNext();) {
- ComponentBean component = (ComponentBean) iter.next();
- info("Create class file "+component.getClassname());
- if (component.isGenerate()) {
- context.put("component", component);
- context.put("renderer", component.getRenderer());
- context.put("package", component.getPackageName());
- Set<String> importClasses = new HashSet<String>();
- for (Iterator it = component.getProperties().iterator(); it
- .hasNext();) {
- PropertyBean property = (PropertyBean) it.next();
- // For non-primitive types, add import declaration.
- if (!property.isSimpleType() && !property.isExist()) {
- importClasses.add(property.getClassname());
- }
- }
- importClasses.add(component.getSuperclass());
- context.put("imports", importClasses);
- String resultPath = component.getClassname().replace('.', '/')
- + ".java";
- File javaFile = new File(getDestDir(), resultPath);
- File javaDir = javaFile.getParentFile();
- if (!javaDir.exists()) {
- javaDir.mkdirs();
- }
- try {
- if (javaFile.exists()) {
- javaFile.delete();
- }
- Writer out = new BufferedWriter(new FileWriter(javaFile));
- template.merge(context, out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw new GeneratorException(
- "Error create new Component Java file ", e);
- }
- }
- }
-
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
- */
- protected String getDefaultTemplateName() {
- // TODO Auto-generated method stub
- return COMPONENT_FILE_TEMPLATE;
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ComponentBean;
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+
+/**
+ * Class implement functionality for generate component java files
+ * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * use in ant build.xml :
+ * <jsfgenerator ... >
+ * ....
+ * <components ... />
+ * ....
+ * </jsfgenerator>
+ * attributes:
+ * {@see com.exadel.vcp.builder.ant.InnerGenerator}
+ * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/20 20:58:00 $
+ *
+ */
+public class ComponentGenerator extends InnerGenerator {
+
+ private static final String COMPONENT_FILE_TEMPLATE = "component.vm";
+ /**
+ * @param task
+ */
+ public ComponentGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task,log);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
+ */
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+ context.put("generator",this);
+ // Put common properties
+ for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
+ ComponentBean component = (ComponentBean) iter.next();
+ info("Create class file "+component.getClassname());
+ if (component.isGenerate()) {
+ context.put("component", component);
+ context.put("renderer", component.getRenderer());
+ context.put("package", component.getPackageName());
+ Set<String> importClasses = new HashSet<String>();
+ for (Iterator it = component.getProperties().iterator(); it
+ .hasNext();) {
+ PropertyBean property = (PropertyBean) it.next();
+ // For non-primitive types, add import declaration.
+ if (!property.isSimpleType() && !property.isExist()) {
+ importClasses.add(property.getClassname());
+ }
+ }
+ importClasses.add(component.getSuperclass());
+ context.put("imports", importClasses);
+ String resultPath = component.getClassname().replace('.', '/')
+ + ".java";
+ File javaFile = new File(getDestDir(), resultPath);
+ File javaDir = javaFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (javaFile.exists()) {
+ javaFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(javaFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error create new Component Java file ", e);
+ }
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
+ */
+ protected String getDefaultTemplateName() {
+ // TODO Auto-generated method stub
+ return COMPONENT_FILE_TEMPLATE;
+ }
+
+}
Copied: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTagGenerator.java (from rev 113, trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagGenerator.java)
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTagGenerator.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTagGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1,144 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ComponentBean;
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.config.TagBean;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+
+/**
+ * Class implement functionality for generate jap tags java files
+ * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * use in ant build.xml :
+ * <jsfgenerator ... >
+ * ....
+ * <tags ... />
+ * ....
+ * </jsfgenerator>
+ * attributes:
+ * {@see com.exadel.vcp.builder.ant.InnerGenerator}
+ * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/20 20:58:01 $
+ *
+ */
+public class ComponentTagGenerator extends InnerGenerator {
+
+ private static final String TAG_TEMPLATE_NAME = "componentTag.vm";
+
+ private String _package = null;
+
+ /**
+ * @return Returns the package.
+ */
+ public String getPackage() {
+ return _package;
+ }
+ /**
+ * @param package1 The package to set.
+ */
+ public void setPackage(String package1) {
+ _package = package1;
+ }
+ /**
+ * @param task
+ */
+ public ComponentTagGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task,log);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
+ */
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ context.put("generator",this);
+ Template template = getTemplate();
+ // Put common properties
+ for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
+ ComponentBean component = (ComponentBean) iter.next();
+ TagBean tag = component.getTag();
+ if ( null != tag && null !=tag.getClassname() && tag.isGenerate()) {
+ info("Create tag class file "+component.getClassname());
+ context.put("component", component);
+ if (null != component.getRenderer()) {
+ context.put("renderer", component.getRenderer());
+ } else {
+ context.put("renderer",Boolean.FALSE);
+ }
+ context.put("tag", component.getTag());
+ context.put("package", component.getTag().getPackageName());
+ Set<String> importClasses = new HashSet<String>();
+ for (Iterator it = component.getProperties().iterator(); it
+ .hasNext();) {
+ PropertyBean property = (PropertyBean) it.next();
+ // For non-primitive types, add import declaration.
+ if (!property.isSimpleType() && !property.isHidden()) {
+ importClasses.add(property.getClassname());
+ }
+ }
+ importClasses.add(component.getTag().getSuperclass());
+ context.put("imports", importClasses);
+ String resultPath = component.getTag().getClassname().replace('.', '/')
+ + ".java";
+ File javaFile = new File(getDestDir(), resultPath);
+ File javaDir = javaFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (javaFile.exists()) {
+ javaFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(javaFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error create new Component JSP Tag Java file ", e);
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
+ */
+ protected String getDefaultTemplateName() {
+ // TODO Auto-generated method stub
+ return TAG_TEMPLATE_NAME;
+ }
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTestGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTestGenerator.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTestGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -32,7 +32,7 @@
context.put("testDataGenerator", new TestDataGenerator(getClassLoader(), getLog()));
// Put common properties
- for (Iterator iter = config.iterator(); iter.hasNext();) {
+ for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
ComponentBean component = (ComponentBean) iter.next();
if(component.getTest() != null){
info("Create component test class file for component "+component.getClassname());
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ConverterGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ConverterGenerator.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ConverterGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1,107 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ConverterBean;
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.config.ValidatorBean;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+
+
+/**
+ * This class generates an implementation of a JSF converter
+ *
+ * Uses the converter.vm velocimacro
+ *
+ */
+public class ConverterGenerator extends InnerGenerator {
+
+ private static final String COMPONENT_FILE_TEMPLATE = "converter.vm";
+ /**
+ * @param task
+ */
+ public ConverterGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task,log);
+ }
+
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+ context.put("generator",this);
+ // Put common properties
+ for (Iterator iter = config.getConverters().iterator(); iter.hasNext();) {
+ ConverterBean converter = (ConverterBean) iter.next();
+ info("Create class file "+converter.getClassname());
+ if (converter.isGenerate()) {
+ context.put("converter", converter);
+ context.put("package", converter.getPackageName());
+ Set<String> importClasses = new HashSet<String>();
+ for (Iterator it = converter.getProperties().iterator(); it
+ .hasNext();) {
+ PropertyBean property = (PropertyBean) it.next();
+ // For non-primitive types, add import declaration.
+ if (!property.isSimpleType() && !property.isExist()) {
+ importClasses.add(property.getClassname());
+ }
+ }
+ importClasses.add(converter.getSuperclass());
+ context.put("imports", importClasses);
+ String resultPath = converter.getClassname().replace('.', '/')
+ + ".java";
+ File javaFile = new File(getDestDir(), resultPath);
+ File javaDir = javaFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (javaFile.exists()) {
+ javaFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(javaFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error generating converter: " + converter.getClassname(), e);
+ }
+ }
+ }
+
+ }
+
+ protected String getDefaultTemplateName() {
+ return COMPONENT_FILE_TEMPLATE;
+ }
+
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ConverterTagGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ConverterTagGenerator.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ConverterTagGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1,137 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ConverterBean;
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.config.TagBean;
+import org.ajax4jsf.builder.config.ValidatorBean;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+
+/**
+ * Class implement functionality for generate jsp tags for validators
+ * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * use in ant build.xml :
+ * <jsfgenerator ... >
+ * ....
+ * <tags ... />
+ * ....
+ * </jsfgenerator>
+ * attributes:
+ * {@see com.exadel.vcp.builder.ant.InnerGenerator}
+ *
+ */
+public class ConverterTagGenerator extends InnerGenerator {
+
+ private static final String TAG_TEMPLATE_NAME = "converterTag.vm";
+
+ private String _package = null;
+
+ /**
+ * @return Returns the package.
+ */
+ public String getPackage() {
+ return _package;
+ }
+ /**
+ * @param package1 The package to set.
+ */
+ public void setPackage(String package1) {
+ _package = package1;
+ }
+ /**
+ * @param task
+ */
+ public ConverterTagGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task,log);
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
+ */
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ context.put("generator",this);
+ Template template = getTemplate();
+ // Put common properties
+ for (Iterator iter = config.getConverters().iterator(); iter.hasNext();) {
+ ConverterBean converter = (ConverterBean) iter.next();
+ TagBean tag = converter.getTag();
+ if ( null != tag && null !=tag.getClassname() && tag.isGenerate()) {
+ info("Create tag class file "+converter.getClassname());
+ context.put("converter", converter);
+
+ context.put("tag", converter.getTag());
+ context.put("package", converter.getTag().getPackageName());
+ Set<String> importClasses = new HashSet<String>();
+ for (Iterator it = converter.getProperties().iterator(); it
+ .hasNext();) {
+ PropertyBean property = (PropertyBean) it.next();
+ // For non-primitive types, add import declaration.
+ if (!property.isSimpleType() && !property.isHidden()) {
+ importClasses.add(property.getClassname());
+ }
+ }
+ importClasses.add(converter.getTag().getSuperclass());
+ context.put("imports", importClasses);
+ String resultPath = converter.getTag().getClassname().replace('.', '/')
+ + ".java";
+ File javaFile = new File(getDestDir(), resultPath);
+ File javaDir = javaFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (javaFile.exists()) {
+ javaFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(javaFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error generating JSP Tag Java file for validator " + converter.getName(), e);
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
+ */
+ protected String getDefaultTemplateName() {
+ return TAG_TEMPLATE_NAME;
+ }
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/FaceletsTaglibGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/FaceletsTaglibGenerator.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/FaceletsTaglibGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,212 +1,258 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.ListenerBean;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-
-/**
- * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.5 $ $Date: 2007/02/20 20:58:00 $
- *
- */
-public class FaceletsTaglibGenerator extends XMLConfigGenerator {
-
- private static final String FACELETS_TAGLIB_TEMPLATE_NAME = "facelets.taglib.vm";
-
- private File _taglib = null;
-
- private String _uri = null;
-
- private String _shortname = null;
-
- private String _description = null;
-
- private String _displayName = null;
-
- /**
- * @param task
- */
- public FaceletsTaglibGenerator(JSFGeneratorConfiguration task, Logger log) {
- super(task,log);
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
- */
- public void createFiles(BuilderConfig config) throws GeneratorException {
- VelocityContext context = new VelocityContext();
- Template template = getTemplate();
- // Put common properties
- List<ComponentBean> compmnents = new ArrayList<ComponentBean>();
- for (Iterator iter = config.iterator(); iter.hasNext();) {
- ComponentBean component = (ComponentBean) iter.next();
- boolean includeComponent = true;
- // Check include patterns
- if (component.getTag() != null || component.getTaghandler() != null) {
- includeComponent = isIncludeComponent(component);
- if (includeComponent) {
- info("Component "+component.getName() +" included to taglib "+getShortname());
- compmnents.add(component);
- } else {
- info("Component "+component.getName() +" excluded from taglib "+getShortname());
- }
- }
- }
-
- List<ListenerBean> listeners = new ArrayList<ListenerBean>();
- for (ListenerBean bean : config.getListeners()) {
- for (ComponentBean componentBean : bean.getSuitableComponents()) {
- if (compmnents.contains(componentBean)) {
- listeners.add(bean);
- break;
- }
- }
- }
-
- if (compmnents.size() > 0) {
- if (listeners.size() > 0) {
- context.put("listeners", listeners);
- }
-
- context.put("components", compmnents);
- context.put("taglib", this);
- File taglibFile = getTaglib();//new File(getDestDir(), resultPath);
- File javaDir = taglibFile.getParentFile();
- if (!javaDir.exists()) {
- javaDir.mkdirs();
- }
- try {
- if (taglibFile.exists()) {
- taglibFile.delete();
- }
- Writer out = new BufferedWriter(new FileWriter(taglibFile));
- template.merge(context, out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw new GeneratorException(
- "Error create new taglib file ", e);
- }
- }
-
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
- */
- protected String getDefaultTemplateName() {
- // TODO Auto-generated method stub
- return FACELETS_TAGLIB_TEMPLATE_NAME;
- }
-
- /**
- * @return Returns the description.
- */
- public String getDescription() {
- return _description;
- }
-
- /**
- * @param description The description to set.
- */
- public void setDescription(String description) {
- _description = description;
- }
-
- /**
- * @return Returns the displayName.
- */
- public String getDisplayName() {
- return _displayName;
- }
-
- /**
- * @param displayName The displayName to set.
- */
- public void setDisplayName(String displayName) {
- _displayName = displayName;
- }
-
- /**
- * @return Returns the shortName.
- */
- public String getShortname() {
- return _shortname;
- }
-
- /**
- * @param shortName The shortName to set.
- */
- public void setShortname(String shortName) {
- _shortname = shortName;
- }
-
- /**
- * @return Returns the taglib.
- */
- public File getTaglib() {
- return _taglib;
- }
-
- /**
- * @param taglib The taglib to set.
- */
- public void setTaglib(File taglib) {
- _taglib = taglib;
- }
-
- /**
- * @return Returns the uri.
- */
- public String getUri() {
- return _uri;
- }
-
- /**
- * @param uri The uri to set.
- */
- public void setUri(String uri) {
- _uri = uri;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.XMLConfigGenerator#getRootTag()
- */
- protected String getRootTag() {
-
- return "facelet-taglib";
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ComponentBean;
+import org.ajax4jsf.builder.config.ConverterBean;
+import org.ajax4jsf.builder.config.ComponentBaseBean;
+import org.ajax4jsf.builder.config.ListenerBean;
+import org.ajax4jsf.builder.config.ValidatorBean;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
+ * @version $Revision: 1.1.2.5 $ $Date: 2007/02/20 20:58:00 $
+ *
+ */
+public class FaceletsTaglibGenerator extends XMLConfigGenerator {
+
+ private static final String FACELETS_TAGLIB_TEMPLATE_NAME = "facelets.taglib.vm";
+
+ private File _taglib = null;
+
+ private String _uri = null;
+
+ private String _shortname = null;
+
+ private String _description = null;
+
+ private String _displayName = null;
+
+ /**
+ * @param task
+ */
+ public FaceletsTaglibGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task,log);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
+ */
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+ // Put common properties
+ List<ComponentBean> components = new ArrayList<ComponentBean>();
+ for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
+ ComponentBean component = (ComponentBean) iter.next();
+ boolean includeComponent = true;
+ // Check include patterns
+ if (component.getTag() != null || component.getTaghandler() != null) {
+ includeComponent = isIncludeComponent(component);
+ if (includeComponent) {
+ info("Component "+component.getName() +" included to taglib "+getShortname());
+ components.add(component);
+ } else {
+ info("Component "+component.getName() +" excluded from taglib "+getShortname());
+ }
+ }
+ }
+
+ List<ValidatorBean> validators = new ArrayList<ValidatorBean>();
+ for (Iterator iter = config.getValidators().iterator(); iter.hasNext();) {
+ ValidatorBean validator = (ValidatorBean) iter.next();
+ boolean includeValidator = true;
+ // Check include patterns
+ if (validator.getTag() != null || validator.getTaghandler() != null) {
+ includeValidator = isIncludeComponent(validator);
+ if (includeValidator) {
+ info("Validator "+validator.getName() +" included to taglib "+getShortname());
+ validators.add(validator);
+ } else {
+ info("Validator "+validator.getName() +" excluded from taglib "+getShortname());
+ }
+ }
+ }
+
+ List<ConverterBean> converters = new ArrayList<ConverterBean>();
+ for (Iterator iter = config.getConverters().iterator(); iter.hasNext();) {
+ ConverterBean converter = (ConverterBean) iter.next();
+ boolean includeConverter = true;
+ // Check include patterns
+ if (converter.getTag() != null || converter.getTaghandler() != null) {
+ includeConverter = isIncludeComponent(converter);
+ if (includeConverter) {
+ info("Converter "+converter.getName() +" included to taglib "+getShortname());
+ converters.add(converter);
+ } else {
+ info("Converter "+converter.getName() +" excluded from taglib "+getShortname());
+ }
+ }
+ }
+
+ List<ListenerBean> listeners = new ArrayList<ListenerBean>();
+ for (ListenerBean bean : config.getListeners()) {
+ for (ComponentBaseBean componentBean : bean.getSuitableComponents()) {
+ if (components.contains(componentBean)) {
+ listeners.add(bean);
+ break;
+ }
+ }
+ }
+
+ if (components.size() > 0 || validators.size() > 0 || converters.size() > 0) {
+ if (listeners.size() > 0) {
+ context.put("listeners", listeners);
+ }
+
+ if (components.size() > 0)
+ {
+ context.put("components", components);
+ }
+ if (validators.size() > 0)
+ {
+ context.put("validators", validators);
+ }
+ if (converters.size() > 0)
+ {
+ context.put("converters", converters);
+ }
+ context.put("taglib", this);
+ File taglibFile = getTaglib();//new File(getDestDir(), resultPath);
+ File javaDir = taglibFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (taglibFile.exists()) {
+ taglibFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(taglibFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error create new taglib file ", e);
+ }
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
+ */
+ protected String getDefaultTemplateName() {
+ // TODO Auto-generated method stub
+ return FACELETS_TAGLIB_TEMPLATE_NAME;
+ }
+
+ /**
+ * @return Returns the description.
+ */
+ public String getDescription() {
+ return _description;
+ }
+
+ /**
+ * @param description The description to set.
+ */
+ public void setDescription(String description) {
+ _description = description;
+ }
+
+ /**
+ * @return Returns the displayName.
+ */
+ public String getDisplayName() {
+ return _displayName;
+ }
+
+ /**
+ * @param displayName The displayName to set.
+ */
+ public void setDisplayName(String displayName) {
+ _displayName = displayName;
+ }
+
+ /**
+ * @return Returns the shortName.
+ */
+ public String getShortname() {
+ return _shortname;
+ }
+
+ /**
+ * @param shortName The shortName to set.
+ */
+ public void setShortname(String shortName) {
+ _shortname = shortName;
+ }
+
+ /**
+ * @return Returns the taglib.
+ */
+ public File getTaglib() {
+ return _taglib;
+ }
+
+ /**
+ * @param taglib The taglib to set.
+ */
+ public void setTaglib(File taglib) {
+ _taglib = taglib;
+ }
+
+ /**
+ * @return Returns the uri.
+ */
+ public String getUri() {
+ return _uri;
+ }
+
+ /**
+ * @param uri The uri to set.
+ */
+ public void setUri(String uri) {
+ _uri = uri;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.generator.XMLConfigGenerator#getRootTag()
+ */
+ protected String getRootTag() {
+
+ return "facelet-taglib";
+ }
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/FacesConfigGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/FacesConfigGenerator.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/FacesConfigGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,174 +1,176 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-
-/**
- * Class implement functionality for generate faces-config file inner element of
- * {@link org.ajax4jsf.builder.ant.JSFGeneratorTask} use in ant build.xml :
- * <jsfgenerator ... > .... <facesconfig ... /> ....
- * </jsfgenerator> attributes: facesconfig - name of faces-config file
- * include - name of file, included in config renderkitid - name of renderkit
- * for renderers renderkitclass - full Java class name of
- * {@link javax.faces.render.RenderKit} implementation
- * {@see com.exadel.vcp.builder.ant.InnerGenerator} Nested elements :
- * <renderkit renderkitid="..." renderkitclass="..." [package="..."] > for
- * generate any of render-kits at time.
- * {@see com.exadel.vcp.builder.ant.RenderKitBean}
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.5 $ $Date: 2007/02/20 20:58:00 $
- *
- */
-public class FacesConfigGenerator extends XMLConfigGenerator {
-
- private static final String FACES_CONFIG_TEMPLATE_NAME = "faces-config.vm";
-
- private File _facesconfig = null;
-
- private List<RenderKitBean> renderKits = new ArrayList<RenderKitBean>();
-
- private ClassLoader _loader;
-
- /**
- * @param task
- */
- public FacesConfigGenerator(JSFGeneratorConfiguration task, Logger log) {
- super(task, log);
- // TODO Auto-generated constructor stub
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
- */
- public void createFiles(BuilderConfig config) throws GeneratorException {
- VelocityContext context = new VelocityContext();
- Template template = getTemplate();
- // Put common properties
- _loader = config.getLoader();
- context.put("components", config.getComponents());
- context.put("renderers", config.getRenderers());
- context.put("facesConfig", this);
- File configFile = getFacesconfig();// new File(getDestDir(),
- // resultPath);
- File javaDir = configFile.getParentFile();
- if (!javaDir.exists()) {
- javaDir.mkdirs();
- }
- try {
- if (configFile.exists()) {
- configFile.delete();
- }
- Writer out = new BufferedWriter(new FileWriter(configFile));
- template.merge(context, out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw new GeneratorException("Error create new faces-config.xml ",
- e);
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
- */
- protected String getDefaultTemplateName() {
- // TODO Auto-generated method stub
- return FACES_CONFIG_TEMPLATE_NAME;
- }
-
- /**
- * @return Returns the taglib.
- */
- public File getFacesconfig() {
- return _facesconfig;
- }
-
- /**
- * @param taglib
- * The taglib to set.
- */
- public void setFacesconfig(File taglib) {
- _facesconfig = taglib;
- }
-
- /**
- * @return Returns the renderKits.
- */
- public List<RenderKitBean> getRenderKits() {
- return renderKits;
- }
-
- /**
- * Create instance of child <renderkit> element
- *
- * @return
- */
- public RenderKitBean createRenderKit() {
- RenderKitBean renderKit = new RenderKitBean();
- this.renderKits.add(renderKit);
- return renderKit;
- }
-
- /**
- * called from a template to validate if a class exists
- *
- * @param className
- * @return
- */
- public boolean rendererExists(String className) {
- boolean exists = false;
- try {
- Class.forName(className, false, _loader);
- exists = true;
- } catch (Exception ex) {
- info("Class " + className
- + " not found, therefore not registered in faces-config");
- }
- return exists;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.builder.generator.XMLConfigGenerator#getRootTag()
- */
- protected String getRootTag() {
-
- return "faces-config";
- }
-}
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * Class implement functionality for generate faces-config file inner element of
+ * {@link org.ajax4jsf.builder.ant.JSFGeneratorTask} use in ant build.xml :
+ * <jsfgenerator ... > .... <facesconfig ... /> ....
+ * </jsfgenerator> attributes: facesconfig - name of faces-config file
+ * include - name of file, included in config renderkitid - name of renderkit
+ * for renderers renderkitclass - full Java class name of
+ * {@link javax.faces.render.RenderKit} implementation
+ * {@see com.exadel.vcp.builder.ant.InnerGenerator} Nested elements :
+ * <renderkit renderkitid="..." renderkitclass="..." [package="..."] > for
+ * generate any of render-kits at time.
+ * {@see com.exadel.vcp.builder.ant.RenderKitBean}
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
+ * @version $Revision: 1.1.2.5 $ $Date: 2007/02/20 20:58:00 $
+ *
+ */
+public class FacesConfigGenerator extends XMLConfigGenerator {
+
+ private static final String FACES_CONFIG_TEMPLATE_NAME = "faces-config.vm";
+
+ private File _facesconfig = null;
+
+ private List<RenderKitBean> renderKits = new ArrayList<RenderKitBean>();
+
+ private ClassLoader _loader;
+
+ /**
+ * @param task
+ */
+ public FacesConfigGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task, log);
+ // TODO Auto-generated constructor stub
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
+ */
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+ // Put common properties
+ _loader = config.getLoader();
+ context.put("components", config.getComponents());
+ context.put("validators", config.getValidators());
+ context.put("converters", config.getConverters());
+ context.put("renderers", config.getRenderers());
+ context.put("facesConfig", this);
+ File configFile = getFacesconfig();// new File(getDestDir(),
+ // resultPath);
+ File javaDir = configFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (configFile.exists()) {
+ configFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(configFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException("Error create new faces-config.xml ",
+ e);
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
+ */
+ protected String getDefaultTemplateName() {
+ // TODO Auto-generated method stub
+ return FACES_CONFIG_TEMPLATE_NAME;
+ }
+
+ /**
+ * @return Returns the taglib.
+ */
+ public File getFacesconfig() {
+ return _facesconfig;
+ }
+
+ /**
+ * @param taglib
+ * The taglib to set.
+ */
+ public void setFacesconfig(File taglib) {
+ _facesconfig = taglib;
+ }
+
+ /**
+ * @return Returns the renderKits.
+ */
+ public List<RenderKitBean> getRenderKits() {
+ return renderKits;
+ }
+
+ /**
+ * Create instance of child <renderkit> element
+ *
+ * @return
+ */
+ public RenderKitBean createRenderKit() {
+ RenderKitBean renderKit = new RenderKitBean();
+ this.renderKits.add(renderKit);
+ return renderKit;
+ }
+
+ /**
+ * called from a template to validate if a class exists
+ *
+ * @param className
+ * @return
+ */
+ public boolean rendererExists(String className) {
+ boolean exists = false;
+ try {
+ Class.forName(className, false, _loader);
+ exists = true;
+ } catch (Exception ex) {
+ info("Class " + className
+ + " not found, therefore not registered in faces-config");
+ }
+ return exists;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.builder.generator.XMLConfigGenerator#getRootTag()
+ */
+ protected String getRootTag() {
+
+ return "faces-config";
+ }
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/InnerGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/InnerGenerator.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/InnerGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,213 +1,214 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.generator;
-
-import java.io.File;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.generator.ClassPatternSet.PatternEntry;
-import org.apache.tools.ant.BuildException;
-import org.apache.velocity.Template;
-
-
-/**
- * Base class for all JSF generators - component java file ,
- * faces-config.xml , jsp tag java file , renderer template, jsp & facelets taglib
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
- * use in ant build.xml :
- * <jsfgenerator ... >
- * ....
- * <inner ... />
- * ....
- * </jsfgenerator>
- * attributes:
- * destdir - override target directory for generated files from task.
- * templatename - override default name for velocity template.
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.7 $ $Date: 2007/02/26 20:48:40 $
- *
- */
-public abstract class InnerGenerator {
-
- /**
- * Destination directory for generated files.
- */
- private File _destDir = null;
-
- /**
- * Name of Velocity template fale for genetation.
- */
- private String _templateName;
-
- private JSFGeneratorConfiguration _config;
-
- private Logger _log;
-
- protected ClassPatternSet _patterns = new ClassPatternSet();
-
-
- /**
- * @param task
- */
- public InnerGenerator(JSFGeneratorConfiguration config, Logger log) {
- // TODO Auto-generated constructor stub
- _config = config;
- _log = log;
- }
-
- /**
- * @return the config
- */
- public JSFGeneratorConfiguration getConfig() {
- return this._config;
- }
-
- /**
- * @param config the config to set
- */
- public void setConfig(JSFGeneratorConfiguration config) {
- this._config = config;
- }
-
- /**
- * @return Returns the destDir.
- * @throws GeneratorException
- */
- public File getDestDir() throws GeneratorException {
- File destDir = _destDir;
- if (null == destDir) {
- destDir = _config.getDestDir();
- }
- if (destDir == null) {
- throw new GeneratorException("Destination directory not set");
- } else if (destDir.exists() && !destDir.isDirectory()) {
- throw new GeneratorException("Destination not is directory");
- }
- if (!destDir.exists()) {
- destDir.mkdirs();
- }
- return destDir;
- }
-
- /**
- * @param destDir The destDir to set.
- */
- public void setDestDir(File destDir) {
- _destDir = destDir;
- }
-
- /**
- * @return Returns the key.
- */
- public String getKey() {
- return this._config.getKey();
- }
-
-
- public ClassLoader getClassLoader(){
- return _config.getClassLoader();
- }
-
- /**
- * @return Returns the template.
- */
- public String getTemplateName() {
- if (null != _templateName) {
- return _templateName;
- } else {
- return _config.getTemplatesPath()+"/"+getDefaultTemplateName();
- }
- }
-
- /**
- * @param template The template to set.
- */
- public void setTemplateName(String template) {
- _templateName = template;
- }
-
- public Template getTemplate() throws GeneratorException {
- return _config.getTemplate(getTemplateName());
- }
-
-
- /**
- * Generate concrete files.
- * @param config
- * @throws BuildException
- */
- public abstract void createFiles(BuilderConfig config) throws GeneratorException;
-
- /**
- * @return default template name for this generator.
- */
- protected abstract String getDefaultTemplateName();
-
- public Logger getLog() {
- return _log;
- }
-
- /* (non-Javadoc)
- * @see org.apache.tools.ant.Task#log(java.lang.String)
- */
- public void info(String arg0) {
- getLog().info(arg0);
- }
-
- /* (non-Javadoc)
- * @see org.apache.tools.ant.Task#log(java.lang.String)
- */
- public void debug(String arg0) {
- getLog().debug(arg0);
- }
-
- public PatternEntry createExclude() {
- return _patterns.createExclude();
- }
-
- public PatternEntry createInclude() {
- return _patterns.createInclude();
- }
-
-
-
- public void setExcludes(String arg0) {
- _patterns.setExcludes(arg0);
- }
-
- public void setIncludes(String arg0) {
- _patterns.setIncludes(arg0);
- }
-
- /**
- * @param includes
- * @param excludes
- * @param component
- * @param includeComponent
- * @return
- */
- protected boolean isIncludeComponent(ComponentBean component) {
- boolean includeComponent = _patterns.matchClass(component.getName());
- return includeComponent;
- }
-}
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.File;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ComponentBean;
+import org.ajax4jsf.builder.config.ComponentBaseBean;
+import org.ajax4jsf.builder.generator.ClassPatternSet.PatternEntry;
+import org.apache.tools.ant.BuildException;
+import org.apache.velocity.Template;
+
+
+/**
+ * Base class for all JSF generators - component java file ,
+ * faces-config.xml , jsp tag java file , renderer template, jsp & facelets taglib
+ * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * use in ant build.xml :
+ * <jsfgenerator ... >
+ * ....
+ * <inner ... />
+ * ....
+ * </jsfgenerator>
+ * attributes:
+ * destdir - override target directory for generated files from task.
+ * templatename - override default name for velocity template.
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.7 $ $Date: 2007/02/26 20:48:40 $
+ *
+ */
+public abstract class InnerGenerator {
+
+ /**
+ * Destination directory for generated files.
+ */
+ private File _destDir = null;
+
+ /**
+ * Name of Velocity template fale for genetation.
+ */
+ private String _templateName;
+
+ private JSFGeneratorConfiguration _config;
+
+ private Logger _log;
+
+ protected ClassPatternSet _patterns = new ClassPatternSet();
+
+
+ /**
+ * @param task
+ */
+ public InnerGenerator(JSFGeneratorConfiguration config, Logger log) {
+ // TODO Auto-generated constructor stub
+ _config = config;
+ _log = log;
+ }
+
+ /**
+ * @return the config
+ */
+ public JSFGeneratorConfiguration getConfig() {
+ return this._config;
+ }
+
+ /**
+ * @param config the config to set
+ */
+ public void setConfig(JSFGeneratorConfiguration config) {
+ this._config = config;
+ }
+
+ /**
+ * @return Returns the destDir.
+ * @throws GeneratorException
+ */
+ public File getDestDir() throws GeneratorException {
+ File destDir = _destDir;
+ if (null == destDir) {
+ destDir = _config.getDestDir();
+ }
+ if (destDir == null) {
+ throw new GeneratorException("Destination directory not set");
+ } else if (destDir.exists() && !destDir.isDirectory()) {
+ throw new GeneratorException("Destination not is directory");
+ }
+ if (!destDir.exists()) {
+ destDir.mkdirs();
+ }
+ return destDir;
+ }
+
+ /**
+ * @param destDir The destDir to set.
+ */
+ public void setDestDir(File destDir) {
+ _destDir = destDir;
+ }
+
+ /**
+ * @return Returns the key.
+ */
+ public String getKey() {
+ return this._config.getKey();
+ }
+
+
+ public ClassLoader getClassLoader(){
+ return _config.getClassLoader();
+ }
+
+ /**
+ * @return Returns the template.
+ */
+ public String getTemplateName() {
+ if (null != _templateName) {
+ return _templateName;
+ } else {
+ return _config.getTemplatesPath()+"/"+getDefaultTemplateName();
+ }
+ }
+
+ /**
+ * @param template The template to set.
+ */
+ public void setTemplateName(String template) {
+ _templateName = template;
+ }
+
+ public Template getTemplate() throws GeneratorException {
+ return _config.getTemplate(getTemplateName());
+ }
+
+
+ /**
+ * Generate concrete files.
+ * @param config
+ * @throws BuildException
+ */
+ public abstract void createFiles(BuilderConfig config) throws GeneratorException;
+
+ /**
+ * @return default template name for this generator.
+ */
+ protected abstract String getDefaultTemplateName();
+
+ public Logger getLog() {
+ return _log;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tools.ant.Task#log(java.lang.String)
+ */
+ public void info(String arg0) {
+ getLog().info(arg0);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.tools.ant.Task#log(java.lang.String)
+ */
+ public void debug(String arg0) {
+ getLog().debug(arg0);
+ }
+
+ public PatternEntry createExclude() {
+ return _patterns.createExclude();
+ }
+
+ public PatternEntry createInclude() {
+ return _patterns.createInclude();
+ }
+
+
+
+ public void setExcludes(String arg0) {
+ _patterns.setExcludes(arg0);
+ }
+
+ public void setIncludes(String arg0) {
+ _patterns.setIncludes(arg0);
+ }
+
+ /**
+ * @param includes
+ * @param excludes
+ * @param component
+ * @param includeComponent
+ * @return
+ */
+ protected boolean isIncludeComponent(ComponentBaseBean component) {
+ boolean includeComponent = _patterns.matchClass(component.getName());
+ return includeComponent;
+ }
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/RendererGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/RendererGenerator.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/RendererGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,198 +1,199 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.io.Writer;
-import java.util.Iterator;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.RendererBean;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.builder.TemplateCompiler;
-
-/**
- * Class implement functionality for generate base renderers java files, for
- * manual extention. If renderer property override in config file set to true,
- * override existing renderers files. inner element of
- * {@link org.ajax4jsf.builder.ant.JSFGeneratorTask} use in ant build.xml :
- * <jsfgenerator ... > .... <renderers ... /> ....
- * </jsfgenerator> attributes: package - optional Java package name for
- * override from configuration, used for create set of differern render-kits in
- * one task {@see com.exadel.vcp.builder.ant.InnerGenerator}
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.10 $ $Date: 2007/02/26 20:48:40 $
- *
- */
-public class RendererGenerator extends InnerGenerator {
-
- private static final String RENDERER_TEMPLATE_NAME = "renderer.vm";
-
- private File _srcDir = null;
-
- /**
- * Optional package name for override from config.
- */
- private String _package = null;
-
- /**
- * @return Returns the package.
- */
- public String getPackage() {
- return _package;
- }
-
- /**
- * @param package1
- * The package to set.
- */
- public void setPackage(String package1) {
- _package = package1;
- }
-
- /**
- * @return the srcDir
- */
- public File getSrcDir() {
- return this._srcDir;
- }
-
- /**
- * @param srcDir
- * the srcDir to set
- */
- public void setSrcDir(File srcDir) {
- this._srcDir = srcDir;
- }
-
- /**
- * @param task
- */
- public RendererGenerator(JSFGeneratorConfiguration task, Logger log) {
- super(task, log);
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
- */
- public void createFiles(BuilderConfig config) throws GeneratorException {
- // Put common properties
- for (Iterator iter = config.iterator(); iter.hasNext();) {
- ComponentBean component = (ComponentBean) iter.next();
- RendererBean renderer = component.getRenderer();
- createRenderer(renderer, component);
- }
- for (Iterator iter = config.getRenderers().iterator(); iter.hasNext();) {
- RendererBean renderer = (RendererBean) iter.next();
- createRenderer(renderer, null);
- }
- }
-
- public void createRenderer(RendererBean renderer, ComponentBean component)
- throws GeneratorException {
- if (null != renderer && renderer.isGenerate()
- && null != renderer.getTemplate()) {
- try {
- File template;
- if (null != getSrcDir()) {
- template = new File(getSrcDir(), renderer.getTemplate());
- } else {
- template = new File(renderer.getTemplate());
- }
- CompilationContext rendererBean = new RendererCompilationContext(
- getLog(), getClassLoader(),getConfig());
- if (null != renderer.getClassname()) {
- rendererBean.setBaseclass(renderer.getClassname());
-
- }
- if (null != renderer.getClassname()) {
- rendererBean.setFullClassName(renderer.getClassname());
- }
- if (null != component) {
- try {
- rendererBean
- .setComponentClass(component.getClassname());
- } catch (CompilationException e) {
- if (null != component.getSuperclass()) {
- rendererBean.setComponentClass(component
- .getSuperclass());
- }
- }
-
- }
- TemplateCompiler templateCompiler = new TemplateCompiler();
- InputStream templateStream = new FileInputStream(template);
- templateCompiler.processing(templateStream, rendererBean);
- renderer.setClassname(rendererBean.getFullClassName());
- String resultPath = rendererBean.getComponentFileName();
- if (null == getPackage()) {
- resultPath = resultPath.replace('.', '/');
- } else {
- resultPath = getPackage().replace('.', '/') + "/"
- + resultPath;
- }
-
- File javaFile = new File(getDestDir(), resultPath + ".java");
- File javaDir = javaFile.getParentFile();
- if (!javaDir.exists()) {
- javaDir.mkdirs();
- }
- if (javaFile.exists()) {
- if (renderer.isOverride()) {
- javaFile.delete();
- } else {
- return;
- }
- }
- Writer out = new BufferedWriter(new FileWriter(javaFile));
- templateCompiler.generateCode(rendererBean, out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw new GeneratorException(
- "Error create Renderer Java file ", e);
- }
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
- */
- protected String getDefaultTemplateName() {
- // TODO Auto-generated method stub
- return RENDERER_TEMPLATE_NAME;
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.Writer;
+import java.util.Iterator;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ComponentBaseBean;
+import org.ajax4jsf.builder.config.ComponentBean;
+import org.ajax4jsf.builder.config.RendererBean;
+import org.ajax4jsf.templatecompiler.builder.CompilationContext;
+import org.ajax4jsf.templatecompiler.builder.CompilationException;
+import org.ajax4jsf.templatecompiler.builder.TemplateCompiler;
+
+/**
+ * Class implement functionality for generate base renderers java files, for
+ * manual extention. If renderer property override in config file set to true,
+ * override existing renderers files. inner element of
+ * {@link org.ajax4jsf.builder.ant.JSFGeneratorTask} use in ant build.xml :
+ * <jsfgenerator ... > .... <renderers ... /> ....
+ * </jsfgenerator> attributes: package - optional Java package name for
+ * override from configuration, used for create set of differern render-kits in
+ * one task {@see com.exadel.vcp.builder.ant.InnerGenerator}
+ *
+ * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.10 $ $Date: 2007/02/26 20:48:40 $
+ *
+ */
+public class RendererGenerator extends InnerGenerator {
+
+ private static final String RENDERER_TEMPLATE_NAME = "renderer.vm";
+
+ private File _srcDir = null;
+
+ /**
+ * Optional package name for override from config.
+ */
+ private String _package = null;
+
+ /**
+ * @return Returns the package.
+ */
+ public String getPackage() {
+ return _package;
+ }
+
+ /**
+ * @param package1
+ * The package to set.
+ */
+ public void setPackage(String package1) {
+ _package = package1;
+ }
+
+ /**
+ * @return the srcDir
+ */
+ public File getSrcDir() {
+ return this._srcDir;
+ }
+
+ /**
+ * @param srcDir
+ * the srcDir to set
+ */
+ public void setSrcDir(File srcDir) {
+ this._srcDir = srcDir;
+ }
+
+ /**
+ * @param task
+ */
+ public RendererGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task, log);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
+ */
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ // Put common properties
+ for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
+ ComponentBean component = (ComponentBean) iter.next();
+ RendererBean renderer = component.getRenderer();
+ createRenderer(renderer, component);
+ }
+ for (Iterator iter = config.getRenderers().iterator(); iter.hasNext();) {
+ RendererBean renderer = (RendererBean) iter.next();
+ createRenderer(renderer, null);
+ }
+ }
+
+ public void createRenderer(RendererBean renderer, ComponentBaseBean component)
+ throws GeneratorException {
+ if (null != renderer && renderer.isGenerate()
+ && null != renderer.getTemplate()) {
+ try {
+ File template;
+ if (null != getSrcDir()) {
+ template = new File(getSrcDir(), renderer.getTemplate());
+ } else {
+ template = new File(renderer.getTemplate());
+ }
+ CompilationContext rendererBean = new RendererCompilationContext(
+ getLog(), getClassLoader(),getConfig());
+ if (null != renderer.getClassname()) {
+ rendererBean.setBaseclass(renderer.getClassname());
+
+ }
+ if (null != renderer.getClassname()) {
+ rendererBean.setFullClassName(renderer.getClassname());
+ }
+ if (null != component) {
+ try {
+ rendererBean
+ .setComponentClass(component.getClassname());
+ } catch (CompilationException e) {
+ if (null != component.getSuperclass()) {
+ rendererBean.setComponentClass(component
+ .getSuperclass());
+ }
+ }
+
+ }
+ TemplateCompiler templateCompiler = new TemplateCompiler();
+ InputStream templateStream = new FileInputStream(template);
+ templateCompiler.processing(templateStream, rendererBean);
+ renderer.setClassname(rendererBean.getFullClassName());
+ String resultPath = rendererBean.getComponentFileName();
+ if (null == getPackage()) {
+ resultPath = resultPath.replace('.', '/');
+ } else {
+ resultPath = getPackage().replace('.', '/') + "/"
+ + resultPath;
+ }
+
+ File javaFile = new File(getDestDir(), resultPath + ".java");
+ File javaDir = javaFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ if (javaFile.exists()) {
+ if (renderer.isOverride()) {
+ javaFile.delete();
+ } else {
+ return;
+ }
+ }
+ Writer out = new BufferedWriter(new FileWriter(javaFile));
+ templateCompiler.generateCode(rendererBean, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error create Renderer Java file ", e);
+ }
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
+ */
+ protected String getDefaultTemplateName() {
+ // TODO Auto-generated method stub
+ return RENDERER_TEMPLATE_NAME;
+ }
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGenerator.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,350 +1,351 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import net.sf.cglib.proxy.MethodInterceptor;
-import net.sf.cglib.proxy.MethodProxy;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.RendererBean;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.builder.TemplateCompiler;
-import org.ajax4jsf.templatecompiler.elements.RootElement;
-import org.ajax4jsf.templatecompiler.elements.TemplateElement;
-import org.ajax4jsf.templatecompiler.elements.vcp.FResourceTemplateElement;
-import org.ajax4jsf.templatecompiler.elements.vcp.HeaderResourceElement;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-
-/**
- * @author Nick - mailto:nbelaevski@exadel.com
- * created 17.04.2007
- *
- */
-public class ResourcesConfigGenerator extends FacesConfigGenerator {
-
- private File resourcesConfig;
- private File templatesDirectory;
-
- public ResourcesConfigGenerator(JSFGeneratorConfiguration task, Logger log) {
- super(task, log);
- }
-
- private void addResources(ResourcesConfigGeneratorBean configBean, TemplateElement templateElement,
- String packageName, RendererBean renderer, BuilderConfig builderConfig) throws ClassNotFoundException {
- if (templateElement instanceof FResourceTemplateElement) {
- FResourceTemplateElement resourceTemplateElement = (FResourceTemplateElement) templateElement;
- String name = resourceTemplateElement.getName();
-
- addResource(name, packageName, configBean);
- } else if (templateElement instanceof RootElement) {
- RootElement rootElement = (RootElement) templateElement;
-
- CompilationContext compilationContext = rootElement.getComponentBean();
-
- String classname = renderer.getClassname();
- int idx = classname.lastIndexOf('.');
- if (idx != -1) {
- packageName = classname.substring(0, idx);
- } else {
- packageName = "";
- }
-
- ClassLoader loader = builderConfig.getLoader();
- Class rClass = loader.loadClass("javax.faces.render.Renderer");
-
- Class cl = null;
-
- try {
- cl = loader.loadClass(classname);
- } catch (ClassNotFoundException e) {
- String superclass = compilationContext.getBaseclassPackageName() + "." + compilationContext.getBaseclassName();
- if (superclass != null) {
- cl = loader.loadClass(superclass);
- }
- }
-
- if (cl != null) {
- GetResourceInterceptor interceptor = new GetResourceInterceptor();
- Object instance = AbstractClassStubBuilder.buildStub(cl, interceptor,
- builderConfig.getLoader());
-
- try {
- Method method = null;
- Object object = null;
-
- Class<?> cl1 = instance.getClass();
- while (cl1 != null && method == null) {
- try {
- method = cl1.getDeclaredMethod("getStyles", null);
- } catch (NoSuchMethodException e) {
- cl1 = cl1.getSuperclass();
- }
- }
-
- if (method != null) {
- method.setAccessible(true);
- object = method.invoke(instance, null);
- List<String> list = interceptor.getList();
- if (list != null) {
- for (String name : list) {
- addResource(name, packageName, configBean);
- }
- }
- }
-
- interceptor.clearList();
-
- method = null;
- cl1 = instance.getClass();
- while (cl1 != null && method == null) {
- try {
- method = cl1.getDeclaredMethod("getScripts", null);
- } catch (NoSuchMethodException e) {
- cl1 = cl1.getSuperclass();
- }
- }
-
- if (method != null) {
- method.setAccessible(true);
- object = method.invoke(instance, null);
- List<String> list = interceptor.getList();
- if (list != null) {
- for (String name : list) {
- addResource(name, packageName, configBean);
- }
- }
- }
- } catch (SecurityException e) {
- builderConfig.getLog().error(e.getMessage(), e);
- } catch (IllegalArgumentException e) {
- builderConfig.getLog().error(e.getMessage(), e);
- } catch (IllegalAccessException e) {
- builderConfig.getLog().error(e.getMessage(), e);
- } catch (InvocationTargetException e) {
- builderConfig.getLog().error(e.getMessage(), e);
- }
- }
- } else if (templateElement instanceof HeaderResourceElement) {
- HeaderResourceElement resourceElement = (HeaderResourceElement) templateElement;
- String[] paths = resourceElement.getResourcePaths();
- if (paths != null) {
- for (int i = 0; i < paths.length; i++) {
- String string = paths[i];
-
- addResource(string, packageName, configBean);
- }
- }
- }
-
- ArrayList<TemplateElement> subElements = templateElement.getSubElements();
- for (TemplateElement element : subElements) {
- addResources(configBean, element, packageName, renderer, builderConfig);
- }
- }
-
- private void addResource(String name, String packageName,
- ResourcesConfigGeneratorBean configBean) {
-
- String resolvedPath = resolveResourcePath(name, packageName);
- if (resolvedPath != null) {
- configBean.addPathResource(name, resolvedPath);
- } else {
- //couldn't resolve, treat as class name
- configBean.addClassResource(name, name);
- }
- }
-
- private String resolveResourcePath(String name, String packageName) {
- if (name.contains("/")) {
- String resolvedName;
-
- if (!name.startsWith("/")) {
- //need to resolve
- StringBuffer normalizedName = new StringBuffer();
- normalizedName.append(packageName.replace('.', '/'));
-
- if (!packageName.endsWith("/")) {
- normalizedName.append('/');
- }
-
- normalizedName.append(name);
-
- resolvedName = normalizedName.toString();
- } else {
- if (name.length() > 0) {
- resolvedName = name.substring(1);
- } else {
- resolvedName = null;
- }
- }
-
- return resolvedName;
- }
-
- return null;
- }
-
- private void addResources(ResourcesConfigGeneratorBean configBean, RendererBean renderer, BuilderConfig builderConfig) throws CompilationException, IOException, ClassNotFoundException {
- if (null != renderer && renderer.isGenerate()
- && null != renderer.getTemplate()) {
-
- File template;
- if (null != getTemplates()) {
- template = new File(getTemplates(), renderer.getTemplate());
- } else {
- template = new File(renderer.getTemplate());
- }
- CompilationContext rendererBean = new RendererCompilationContext(
- getLog(), getClassLoader(),getConfig());
-
- TemplateCompiler templateCompiler = new TemplateCompiler();
- InputStream templateStream = new FileInputStream(template);
- templateCompiler.processing(templateStream, rendererBean);
-
- TemplateElement root = rendererBean.getTree();
-
- String classname = renderer.getClassname();
- String packageName;
- int idx = classname.lastIndexOf('.');
- if (idx != -1) {
- packageName = classname.substring(0, idx);
- } else {
- packageName = "";
- }
-
- addResources(configBean, root, packageName, renderer, builderConfig);
- }
- }
-
- public void createFiles(BuilderConfig config) throws GeneratorException {
- VelocityContext context = new VelocityContext();
- Template template = getTemplate();
- try {
- // Put common properties
-
- ResourcesConfigGeneratorBean bean = new ResourcesConfigGeneratorBean();
-
- List<ComponentBean> components = config.getComponents();
- for (ComponentBean componentBean : components) {
- RendererBean rendererBean = componentBean.getRenderer();
-
- addResources(bean, rendererBean, config);
- }
-
- List<RendererBean> renderers = config.getRenderers();
- for (RendererBean rendererBean : renderers) {
- addResources(bean, rendererBean, config);
- }
-
- context.put("classResources", bean.getClassResources());
- context.put("pathResources", bean.getPathResources());
- context.put("facesConfig", this);
- File configFile = getResourcesConfig();
- File javaDir = configFile.getParentFile();
- if (!javaDir.exists()) {
- javaDir.mkdirs();
- }
- if (configFile.exists()) {
- configFile.delete();
- }
- Writer out = new BufferedWriter(new FileWriter(configFile));
- template.merge(context, out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw new GeneratorException("Error create new resources-config.xml ",
- e);
- }
- }
-
- protected String getRootTag() {
- return "resource-config";
- }
-
- public File getResourcesConfig() {
- return resourcesConfig;
- }
-
- public void setResourcesConfig(File resourcesConfig) {
- this.resourcesConfig = resourcesConfig;
- }
-
- protected String getDefaultTemplateName() {
- return "resources-config.vm";
- }
-
- public void setTemplates(File templatesDirectory) {
- this.templatesDirectory = templatesDirectory;
- }
-
- public File getTemplates() {
- return this.templatesDirectory;
- }
-}
-
-class GetResourceInterceptor implements MethodInterceptor {
-
- private static final Class<?>[] SIGNATURE = new Class<?>[] {
- String.class
- };
-
- private List<String> list = new ArrayList<String>();
-
- public List<String> getList() {
- return list;
- }
-
- public void clearList() {
- list.clear();
- }
-
- public Object intercept(Object instance, Method method, Object[] args,
- MethodProxy methodProxy) throws Throwable {
-
- if ("getResource".equals(method.getName()) &&
- Arrays.equals(SIGNATURE, method.getParameterTypes())) {
-
- list.add((String) args[0]);
-
- return null;
- } else {
- return methodProxy.invokeSuper(instance, args);
- }
- }
-
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Writer;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ComponentBean;
+import org.ajax4jsf.builder.config.ComponentBaseBean;
+import org.ajax4jsf.builder.config.RendererBean;
+import org.ajax4jsf.templatecompiler.builder.CompilationContext;
+import org.ajax4jsf.templatecompiler.builder.CompilationException;
+import org.ajax4jsf.templatecompiler.builder.TemplateCompiler;
+import org.ajax4jsf.templatecompiler.elements.RootElement;
+import org.ajax4jsf.templatecompiler.elements.TemplateElement;
+import org.ajax4jsf.templatecompiler.elements.vcp.FResourceTemplateElement;
+import org.ajax4jsf.templatecompiler.elements.vcp.HeaderResourceElement;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 17.04.2007
+ *
+ */
+public class ResourcesConfigGenerator extends FacesConfigGenerator {
+
+ private File resourcesConfig;
+ private File templatesDirectory;
+
+ public ResourcesConfigGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task, log);
+ }
+
+ private void addResources(ResourcesConfigGeneratorBean configBean, TemplateElement templateElement,
+ String packageName, RendererBean renderer, BuilderConfig builderConfig) throws ClassNotFoundException {
+ if (templateElement instanceof FResourceTemplateElement) {
+ FResourceTemplateElement resourceTemplateElement = (FResourceTemplateElement) templateElement;
+ String name = resourceTemplateElement.getName();
+
+ addResource(name, packageName, configBean);
+ } else if (templateElement instanceof RootElement) {
+ RootElement rootElement = (RootElement) templateElement;
+
+ CompilationContext compilationContext = rootElement.getComponentBean();
+
+ String classname = renderer.getClassname();
+ int idx = classname.lastIndexOf('.');
+ if (idx != -1) {
+ packageName = classname.substring(0, idx);
+ } else {
+ packageName = "";
+ }
+
+ ClassLoader loader = builderConfig.getLoader();
+ Class rClass = loader.loadClass("javax.faces.render.Renderer");
+
+ Class cl = null;
+
+ try {
+ cl = loader.loadClass(classname);
+ } catch (ClassNotFoundException e) {
+ String superclass = compilationContext.getBaseclassPackageName() + "." + compilationContext.getBaseclassName();
+ if (superclass != null) {
+ cl = loader.loadClass(superclass);
+ }
+ }
+
+ if (cl != null) {
+ GetResourceInterceptor interceptor = new GetResourceInterceptor();
+ Object instance = AbstractClassStubBuilder.buildStub(cl, interceptor,
+ builderConfig.getLoader());
+
+ try {
+ Method method = null;
+ Object object = null;
+
+ Class<?> cl1 = instance.getClass();
+ while (cl1 != null && method == null) {
+ try {
+ method = cl1.getDeclaredMethod("getStyles", null);
+ } catch (NoSuchMethodException e) {
+ cl1 = cl1.getSuperclass();
+ }
+ }
+
+ if (method != null) {
+ method.setAccessible(true);
+ object = method.invoke(instance, null);
+ List<String> list = interceptor.getList();
+ if (list != null) {
+ for (String name : list) {
+ addResource(name, packageName, configBean);
+ }
+ }
+ }
+
+ interceptor.clearList();
+
+ method = null;
+ cl1 = instance.getClass();
+ while (cl1 != null && method == null) {
+ try {
+ method = cl1.getDeclaredMethod("getScripts", null);
+ } catch (NoSuchMethodException e) {
+ cl1 = cl1.getSuperclass();
+ }
+ }
+
+ if (method != null) {
+ method.setAccessible(true);
+ object = method.invoke(instance, null);
+ List<String> list = interceptor.getList();
+ if (list != null) {
+ for (String name : list) {
+ addResource(name, packageName, configBean);
+ }
+ }
+ }
+ } catch (SecurityException e) {
+ builderConfig.getLog().error(e.getMessage(), e);
+ } catch (IllegalArgumentException e) {
+ builderConfig.getLog().error(e.getMessage(), e);
+ } catch (IllegalAccessException e) {
+ builderConfig.getLog().error(e.getMessage(), e);
+ } catch (InvocationTargetException e) {
+ builderConfig.getLog().error(e.getMessage(), e);
+ }
+ }
+ } else if (templateElement instanceof HeaderResourceElement) {
+ HeaderResourceElement resourceElement = (HeaderResourceElement) templateElement;
+ String[] paths = resourceElement.getResourcePaths();
+ if (paths != null) {
+ for (int i = 0; i < paths.length; i++) {
+ String string = paths[i];
+
+ addResource(string, packageName, configBean);
+ }
+ }
+ }
+
+ ArrayList<TemplateElement> subElements = templateElement.getSubElements();
+ for (TemplateElement element : subElements) {
+ addResources(configBean, element, packageName, renderer, builderConfig);
+ }
+ }
+
+ private void addResource(String name, String packageName,
+ ResourcesConfigGeneratorBean configBean) {
+
+ String resolvedPath = resolveResourcePath(name, packageName);
+ if (resolvedPath != null) {
+ configBean.addPathResource(name, resolvedPath);
+ } else {
+ //couldn't resolve, treat as class name
+ configBean.addClassResource(name, name);
+ }
+ }
+
+ private String resolveResourcePath(String name, String packageName) {
+ if (name.contains("/")) {
+ String resolvedName;
+
+ if (!name.startsWith("/")) {
+ //need to resolve
+ StringBuffer normalizedName = new StringBuffer();
+ normalizedName.append(packageName.replace('.', '/'));
+
+ if (!packageName.endsWith("/")) {
+ normalizedName.append('/');
+ }
+
+ normalizedName.append(name);
+
+ resolvedName = normalizedName.toString();
+ } else {
+ if (name.length() > 0) {
+ resolvedName = name.substring(1);
+ } else {
+ resolvedName = null;
+ }
+ }
+
+ return resolvedName;
+ }
+
+ return null;
+ }
+
+ private void addResources(ResourcesConfigGeneratorBean configBean, RendererBean renderer, BuilderConfig builderConfig) throws CompilationException, IOException, ClassNotFoundException {
+ if (null != renderer && renderer.isGenerate()
+ && null != renderer.getTemplate()) {
+
+ File template;
+ if (null != getTemplates()) {
+ template = new File(getTemplates(), renderer.getTemplate());
+ } else {
+ template = new File(renderer.getTemplate());
+ }
+ CompilationContext rendererBean = new RendererCompilationContext(
+ getLog(), getClassLoader(),getConfig());
+
+ TemplateCompiler templateCompiler = new TemplateCompiler();
+ InputStream templateStream = new FileInputStream(template);
+ templateCompiler.processing(templateStream, rendererBean);
+
+ TemplateElement root = rendererBean.getTree();
+
+ String classname = renderer.getClassname();
+ String packageName;
+ int idx = classname.lastIndexOf('.');
+ if (idx != -1) {
+ packageName = classname.substring(0, idx);
+ } else {
+ packageName = "";
+ }
+
+ addResources(configBean, root, packageName, renderer, builderConfig);
+ }
+ }
+
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+ try {
+ // Put common properties
+
+ ResourcesConfigGeneratorBean bean = new ResourcesConfigGeneratorBean();
+
+ List<ComponentBean> components = config.getComponents();
+ for (ComponentBean componentBean : components) {
+ RendererBean rendererBean = componentBean.getRenderer();
+
+ addResources(bean, rendererBean, config);
+ }
+
+ List<RendererBean> renderers = config.getRenderers();
+ for (RendererBean rendererBean : renderers) {
+ addResources(bean, rendererBean, config);
+ }
+
+ context.put("classResources", bean.getClassResources());
+ context.put("pathResources", bean.getPathResources());
+ context.put("facesConfig", this);
+ File configFile = getResourcesConfig();
+ File javaDir = configFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ if (configFile.exists()) {
+ configFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(configFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException("Error create new resources-config.xml ",
+ e);
+ }
+ }
+
+ protected String getRootTag() {
+ return "resource-config";
+ }
+
+ public File getResourcesConfig() {
+ return resourcesConfig;
+ }
+
+ public void setResourcesConfig(File resourcesConfig) {
+ this.resourcesConfig = resourcesConfig;
+ }
+
+ protected String getDefaultTemplateName() {
+ return "resources-config.vm";
+ }
+
+ public void setTemplates(File templatesDirectory) {
+ this.templatesDirectory = templatesDirectory;
+ }
+
+ public File getTemplates() {
+ return this.templatesDirectory;
+ }
+}
+
+class GetResourceInterceptor implements MethodInterceptor {
+
+ private static final Class<?>[] SIGNATURE = new Class<?>[] {
+ String.class
+ };
+
+ private List<String> list = new ArrayList<String>();
+
+ public List<String> getList() {
+ return list;
+ }
+
+ public void clearList() {
+ list.clear();
+ }
+
+ public Object intercept(Object instance, Method method, Object[] args,
+ MethodProxy methodProxy) throws Throwable {
+
+ if ("getResource".equals(method.getName()) &&
+ Arrays.equals(SIGNATURE, method.getParameterTypes())) {
+
+ list.add((String) args[0]);
+
+ return null;
+ } else {
+ return methodProxy.invokeSuper(instance, args);
+ }
+ }
+
}
\ No newline at end of file
Deleted: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagGenerator.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,144 +0,0 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.config.TagBean;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-
-
-/**
- * Class implement functionality for generate jap tags java files
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
- * use in ant build.xml :
- * <jsfgenerator ... >
- * ....
- * <tags ... />
- * ....
- * </jsfgenerator>
- * attributes:
- * {@see com.exadel.vcp.builder.ant.InnerGenerator}
- * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/20 20:58:01 $
- *
- */
-public class TagGenerator extends InnerGenerator {
-
- private static final String TAG_TEMPLATE_NAME = "tag.vm";
-
- private String _package = null;
-
- /**
- * @return Returns the package.
- */
- public String getPackage() {
- return _package;
- }
- /**
- * @param package1 The package to set.
- */
- public void setPackage(String package1) {
- _package = package1;
- }
- /**
- * @param task
- */
- public TagGenerator(JSFGeneratorConfiguration task, Logger log) {
- super(task,log);
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
- */
- public void createFiles(BuilderConfig config) throws GeneratorException {
- VelocityContext context = new VelocityContext();
- context.put("generator",this);
- Template template = getTemplate();
- // Put common properties
- for (Iterator iter = config.iterator(); iter.hasNext();) {
- ComponentBean component = (ComponentBean) iter.next();
- TagBean tag = component.getTag();
- if ( null != tag && null !=tag.getClassname() && tag.isGenerate()) {
- info("Create tag class file "+component.getClassname());
- context.put("component", component);
- if (null != component.getRenderer()) {
- context.put("renderer", component.getRenderer());
- } else {
- context.put("renderer",Boolean.FALSE);
- }
- context.put("tag", component.getTag());
- context.put("package", component.getTag().getPackageName());
- Set<String> importClasses = new HashSet<String>();
- for (Iterator it = component.getProperties().iterator(); it
- .hasNext();) {
- PropertyBean property = (PropertyBean) it.next();
- // For non-primitive types, add import declaration.
- if (!property.isSimpleType() && !property.isHidden()) {
- importClasses.add(property.getClassname());
- }
- }
- importClasses.add(component.getTag().getSuperclass());
- context.put("imports", importClasses);
- String resultPath = component.getTag().getClassname().replace('.', '/')
- + ".java";
- File javaFile = new File(getDestDir(), resultPath);
- File javaDir = javaFile.getParentFile();
- if (!javaDir.exists()) {
- javaDir.mkdirs();
- }
- try {
- if (javaFile.exists()) {
- javaFile.delete();
- }
- Writer out = new BufferedWriter(new FileWriter(javaFile));
- template.merge(context, out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw new GeneratorException(
- "Error create new Component JSP Tag Java file ", e);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
- */
- protected String getDefaultTemplateName() {
- // TODO Auto-generated method stub
- return TAG_TEMPLATE_NAME;
- }
-
-}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagHandlerGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagHandlerGenerator.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagHandlerGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,142 +1,142 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.config.TagHandlerBean;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-
-
-/**
- * Class implement functionality for generate facelets tags java files
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
- * use in ant build.xml :
- * <jsfgenerator ... >
- * ....
- * <tagsupport ... />
- * ....
- * </jsfgenerator>
- * attributes:
- * {@see com.exadel.vcp.builder.ant.InnerGenerator}
- * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/20 20:58:01 $
- *
- */
-public class TagHandlerGenerator extends InnerGenerator {
-
- private static final String TAG_TEMPLATE_NAME = "taghandler.vm";
-
- private String _package = null;
-
- /**
- * @return Returns the package.
- */
- public String getPackage() {
- return _package;
- }
- /**
- * @param package1 The package to set.
- */
- public void setPackage(String package1) {
- _package = package1;
- }
- /**
- * @param task
- */
- public TagHandlerGenerator(JSFGeneratorConfiguration task, Logger log) {
- super(task,log);
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
- */
- public void createFiles(BuilderConfig config) throws GeneratorException {
- VelocityContext context = new VelocityContext();
- Template template = getTemplate();
- // Put common properties
- for (Iterator iter = config.iterator(); iter.hasNext();) {
- ComponentBean component = (ComponentBean) iter.next();
- TagHandlerBean tagHandler = component.getTaghandler();
- if ( null != tagHandler && tagHandler.isGenerate() && null !=tagHandler.getClassname()) {
- context.put("component", component);
- if (null != component.getRenderer()) {
- context.put("renderer", component.getRenderer());
- } else {
- context.put("renderer",Boolean.FALSE);
- }
- context.put("tag", tagHandler);
- context.put("package", tagHandler.getPackageName());
- Set<String> importClasses = new HashSet<String>();
- for (Iterator it = component.getProperties().iterator(); it
- .hasNext();) {
- PropertyBean property = (PropertyBean) it.next();
- // For non-primitive types, add import declaration.
- if (!property.isSimpleType() && !property.isHidden()) {
- importClasses.add(property.getClassname());
- }
- }
- importClasses.add(tagHandler.getSuperclass());
- context.put("imports", importClasses);
- String resultPath = tagHandler.getClassname().replace('.', '/')
- + ".java";
- File javaFile = new File(getDestDir(), resultPath);
- File javaDir = javaFile.getParentFile();
- if (!javaDir.exists()) {
- javaDir.mkdirs();
- }
- try {
- if (javaFile.exists()) {
- javaFile.delete();
- }
- Writer out = new BufferedWriter(new FileWriter(javaFile));
- template.merge(context, out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw new GeneratorException(
- "Error create new Component Facelets Tag Java file ", e);
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
- */
- protected String getDefaultTemplateName() {
- // TODO Auto-generated method stub
- return TAG_TEMPLATE_NAME;
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ComponentBean;
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.config.TagHandlerBean;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+
+/**
+ * Class implement functionality for generate facelets tags java files
+ * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * use in ant build.xml :
+ * <jsfgenerator ... >
+ * ....
+ * <tagsupport ... />
+ * ....
+ * </jsfgenerator>
+ * attributes:
+ * {@see com.exadel.vcp.builder.ant.InnerGenerator}
+ * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/20 20:58:01 $
+ *
+ */
+public class TagHandlerGenerator extends InnerGenerator {
+
+ private static final String TAG_TEMPLATE_NAME = "taghandler.vm";
+
+ private String _package = null;
+
+ /**
+ * @return Returns the package.
+ */
+ public String getPackage() {
+ return _package;
+ }
+ /**
+ * @param package1 The package to set.
+ */
+ public void setPackage(String package1) {
+ _package = package1;
+ }
+ /**
+ * @param task
+ */
+ public TagHandlerGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task,log);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
+ */
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+ // Put common properties
+ for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
+ ComponentBean component = (ComponentBean) iter.next();
+ TagHandlerBean tagHandler = component.getTaghandler();
+ if ( null != tagHandler && tagHandler.isGenerate() && null !=tagHandler.getClassname()) {
+ context.put("component", component);
+ if (null != component.getRenderer()) {
+ context.put("renderer", component.getRenderer());
+ } else {
+ context.put("renderer",Boolean.FALSE);
+ }
+ context.put("tag", tagHandler);
+ context.put("package", tagHandler.getPackageName());
+ Set<String> importClasses = new HashSet<String>();
+ for (Iterator it = component.getProperties().iterator(); it
+ .hasNext();) {
+ PropertyBean property = (PropertyBean) it.next();
+ // For non-primitive types, add import declaration.
+ if (!property.isSimpleType() && !property.isHidden()) {
+ importClasses.add(property.getClassname());
+ }
+ }
+ importClasses.add(tagHandler.getSuperclass());
+ context.put("imports", importClasses);
+ String resultPath = tagHandler.getClassname().replace('.', '/')
+ + ".java";
+ File javaFile = new File(getDestDir(), resultPath);
+ File javaDir = javaFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (javaFile.exists()) {
+ javaFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(javaFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error create new Component Facelets Tag Java file ", e);
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
+ */
+ protected String getDefaultTemplateName() {
+ // TODO Auto-generated method stub
+ return TAG_TEMPLATE_NAME;
+ }
+
+}
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagTestGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagTestGenerator.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagTestGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -32,7 +32,7 @@
context.put("generator",this);
Template template = getTemplate();
// Put common properties
- for (Iterator iter = config.iterator(); iter.hasNext();) {
+ for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
ComponentBean component = (ComponentBean) iter.next();
TagBean tag = component.getTag();
if ( null != tag && null !=tag.getClassname() && tag.isGenerate()
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TaglibGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TaglibGenerator.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TaglibGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,288 +1,328 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-
-
-/**
- * Class implement functionality for generate jsp taglib .tld file
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
- * use in ant build.xml :
- * <jsfgenerator ... >
- * ....
- * <taglib ... />
- * ....
- * </jsfgenerator>
- * attributes:
- * taglib - name of .tld file
- * Next properties use for common tld elements :
- * uri - taglib uri
- * shortname -
- * description - taglib description
- * displayname
- * tlibversion , default 1.2
- * jspversion , default 2.0
- * listenerclass - full java name of context listener class
- * validatorclass - full java name of jsp validator class
- * include - name of file, included in tld before first tag element
- * For include-exclude components ( by component type ) from taglib, can be used attributes
- * includes or excludes , and nested elements <include ... /> and <exclude ... />
- * with same sintax as other ant tasks
- * {@see com.exadel.vcp.builder.ant.InnerGenerator}
- * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.4 $ $Date: 2007/02/20 20:58:02 $
- *
- */
-public class TaglibGenerator extends XMLConfigGenerator {
-
- private static final String TAGLIB_TEMPLATE_NAME = "taglib.vm";
-
- private File _taglib = null;
-
- private String _uri = null;
-
- private String _shortname = null;
-
- private String _description = null;
-
- private String _displayname = null;
-
- private String _tlibversion = "1.2";
-
- private String _jspversion = "2.0";
-
- private String _listenerclass = null;
-
- private String _validatorclass = null;
-
- /**
- * @param task
- */
- public TaglibGenerator(JSFGeneratorConfiguration task, Logger log) {
- super(task,log);
-// _patterns.setProject(task.getProject());
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
- */
- public void createFiles(BuilderConfig config) throws GeneratorException {
- // parsecomponents aganist patterns.
- List<ComponentBean> compmnents = new ArrayList<ComponentBean>();
- for (Iterator iter = config.iterator(); iter.hasNext();) {
- ComponentBean component = (ComponentBean) iter.next();
- boolean includeComponent = true;
- // Check include patterns
- if (component.getTag() != null && (component.getTag().getTaglib() == null || component.getTag().getTaglib().equals(getShortname()))) {
- includeComponent = isIncludeComponent(component);
- if (includeComponent) {
- info("Component "+component.getName() +" included to taglib "+getShortname());
- compmnents.add(component);
- } else {
- info("Component "+component.getName() +" excluded from taglib "+getShortname());
- }
- }
- }
- if (compmnents.size() > 0) {
- VelocityContext context = new VelocityContext();
- Template template = getTemplate();
- // Put common properties
- context.put("components", compmnents);
- context.put("taglib", this);
- File taglibFile = getTaglib();//new File(getDestDir(), resultPath);
- File javaDir = taglibFile.getParentFile();
- if (!javaDir.exists()) {
- javaDir.mkdirs();
- }
- try {
- if (taglibFile.exists()) {
- taglibFile.delete();
- }
- Writer out = new BufferedWriter(new FileWriter(taglibFile));
- template.merge(context, out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw new GeneratorException("Error create new taglib file ", e);
- }
- } else {
- info("Not have components included in taglib "+getShortname());
- }
-
- }
-
- /* (non-Javadoc)
- * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
- */
- protected String getDefaultTemplateName() {
- // TODO Auto-generated method stub
- return TAGLIB_TEMPLATE_NAME;
- }
-
- /**
- * @return Returns the description.
- */
- public String getDescription() {
- return _description;
- }
-
- /**
- * @param description The description to set.
- */
- public void setDescription(String description) {
- _description = description;
- }
-
- /**
- * @return Returns the displayName.
- */
- public String getDisplayname() {
- return _displayname;
- }
-
- /**
- * @param displayName The displayName to set.
- */
- public void setDisplayname(String displayName) {
- _displayname = displayName;
- }
-
- /**
- * @return Returns the jspVersion.
- */
- public String getJspversion() {
- return _jspversion;
- }
-
- /**
- * @param jspVersion The jspVersion to set.
- */
- public void setJspversion(String jspVersion) {
- _jspversion = jspVersion;
- }
-
- /**
- * @return Returns the listenerClass.
- */
- public String getListenerclass() {
- return _listenerclass;
- }
-
- /**
- * @param listenerClass The listenerClass to set.
- */
- public void setListenerclass(String listenerClass) {
- _listenerclass = listenerClass;
- }
-
- /**
- * @return Returns the shortName.
- */
- public String getShortname() {
- return _shortname;
- }
-
- /**
- * @param shortName The shortName to set.
- */
- public void setShortname(String shortName) {
- _shortname = shortName;
- }
-
- /**
- * @return Returns the taglib.
- */
- public File getTaglib() {
- return _taglib;
- }
-
- /**
- * @param taglib The taglib to set.
- */
- public void setTaglib(File taglib) {
- _taglib = taglib;
- }
-
- /**
- * @return Returns the tlibVersion.
- */
- public String getTlibversion() {
- return _tlibversion;
- }
-
- /**
- * @param tlibVersion The tlibVersion to set.
- */
- public void setTlibversion(String tlibVersion) {
- _tlibversion = tlibVersion;
- }
-
- /**
- * @return Returns the uri.
- */
- public String getUri() {
- return _uri;
- }
-
- /**
- * @param uri The uri to set.
- */
- public void setUri(String uri) {
- _uri = uri;
- }
-
- /**
- * @return Returns the validatorClass.
- */
- public String getValidatorclass() {
- return _validatorclass;
- }
-
- /**
- * @param validatorClass The validatorClass to set.
- */
- public void setValidatorclass(String validatorClass) {
- _validatorclass = validatorClass;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.XMLConfigGenerator#getRootTag()
- */
- protected String getRootTag() {
- //
- return "taglib";
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ComponentBean;
+import org.ajax4jsf.builder.config.ConverterBean;
+import org.ajax4jsf.builder.config.ValidatorBean;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+
+/**
+ * Class implement functionality for generate jsp taglib .tld file
+ * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * use in ant build.xml :
+ * <jsfgenerator ... >
+ * ....
+ * <taglib ... />
+ * ....
+ * </jsfgenerator>
+ * attributes:
+ * taglib - name of .tld file
+ * Next properties use for common tld elements :
+ * uri - taglib uri
+ * shortname -
+ * description - taglib description
+ * displayname
+ * tlibversion , default 1.2
+ * jspversion , default 2.0
+ * listenerclass - full java name of context listener class
+ * validatorclass - full java name of jsp validator class
+ * include - name of file, included in tld before first tag element
+ * For include-exclude components ( by component type ) from taglib, can be used attributes
+ * includes or excludes , and nested elements <include ... /> and <exclude ... />
+ * with same sintax as other ant tasks
+ * {@see com.exadel.vcp.builder.ant.InnerGenerator}
+ * @author asmirnov(a)exadel.com (latest modification by $Author: ishabalov $)
+ * @version $Revision: 1.1.2.4 $ $Date: 2007/02/20 20:58:02 $
+ *
+ */
+public class TaglibGenerator extends XMLConfigGenerator {
+
+ private static final String TAGLIB_TEMPLATE_NAME = "taglib.vm";
+
+ private File _taglib = null;
+
+ private String _uri = null;
+
+ private String _shortname = null;
+
+ private String _description = null;
+
+ private String _displayname = null;
+
+ private String _tlibversion = "1.2";
+
+ private String _jspversion = "2.0";
+
+ private String _listenerclass = null;
+
+ private String _validatorclass = null;
+
+ /**
+ * @param task
+ */
+ public TaglibGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task,log);
+// _patterns.setProject(task.getProject());
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
+ */
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ // parsecomponents aganist patterns.
+ List<ComponentBean> compmnents = new ArrayList<ComponentBean>();
+ for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
+ ComponentBean component = (ComponentBean) iter.next();
+ boolean includeComponent = true;
+ // Check include patterns
+ if (component.getTag() != null && (component.getTag().getTaglib() == null || component.getTag().getTaglib().equals(getShortname()))) {
+ includeComponent = isIncludeComponent(component);
+ if (includeComponent) {
+ info("Component "+component.getName() +" included in taglib "+getShortname());
+ compmnents.add(component);
+ } else {
+ info("Component "+component.getName() +" excluded from taglib "+getShortname());
+ }
+ }
+ }
+ List<ValidatorBean> validators = new ArrayList<ValidatorBean>();
+ for (Iterator iter = config.getValidators().iterator(); iter.hasNext();) {
+ ValidatorBean validator = (ValidatorBean) iter.next();
+ boolean includeComponent = true;
+ // Check include patterns
+ if (validator.getTag() != null && (validator.getTag().getTaglib() == null || validator.getTag().getTaglib().equals(getShortname()))) {
+ includeComponent = isIncludeComponent(validator);
+ if (includeComponent) {
+ info("Validator "+validator.getName() +" included in taglib "+getShortname());
+ validators.add(validator);
+ } else {
+ info("Validator "+validator.getName() +" excluded from taglib "+getShortname());
+ }
+ }
+ }
+ List<ConverterBean> converters = new ArrayList<ConverterBean>();
+ for (Iterator iter = config.getConverters().iterator(); iter.hasNext();) {
+ ConverterBean converter = (ConverterBean) iter.next();
+ boolean includeComponent = true;
+ // Check include patterns
+ if (converter.getTag() != null && (converter.getTag().getTaglib() == null || converter.getTag().getTaglib().equals(getShortname()))) {
+ includeComponent = isIncludeComponent(converter);
+ if (includeComponent) {
+ info("Converter "+converter.getName() +" included in taglib "+getShortname());
+ converters.add(converter);
+ } else {
+ info("Converter "+converter.getName() +" excluded from taglib "+getShortname());
+ }
+ }
+ }
+ if (compmnents.size() > 0 || validators.size() > 0 || converters.size() > 0) {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+ // Put common properties
+ if (compmnents.size() > 0) {
+ context.put("components", compmnents);
+ }
+ if (validators.size() > 0) {
+ context.put("validators", validators);
+ }
+ if (converters.size() > 0) {
+ context.put("converters", converters);
+ }
+ context.put("taglib", this);
+ File taglibFile = getTaglib();//new File(getDestDir(), resultPath);
+ File javaDir = taglibFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (taglibFile.exists()) {
+ taglibFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(taglibFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException("Error create new taglib file ", e);
+ }
+ } else {
+ info("No components included in taglib "+getShortname());
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
+ */
+ protected String getDefaultTemplateName() {
+ // TODO Auto-generated method stub
+ return TAGLIB_TEMPLATE_NAME;
+ }
+
+ /**
+ * @return Returns the description.
+ */
+ public String getDescription() {
+ return _description;
+ }
+
+ /**
+ * @param description The description to set.
+ */
+ public void setDescription(String description) {
+ _description = description;
+ }
+
+ /**
+ * @return Returns the displayName.
+ */
+ public String getDisplayname() {
+ return _displayname;
+ }
+
+ /**
+ * @param displayName The displayName to set.
+ */
+ public void setDisplayname(String displayName) {
+ _displayname = displayName;
+ }
+
+ /**
+ * @return Returns the jspVersion.
+ */
+ public String getJspversion() {
+ return _jspversion;
+ }
+
+ /**
+ * @param jspVersion The jspVersion to set.
+ */
+ public void setJspversion(String jspVersion) {
+ _jspversion = jspVersion;
+ }
+
+ /**
+ * @return Returns the listenerClass.
+ */
+ public String getListenerclass() {
+ return _listenerclass;
+ }
+
+ /**
+ * @param listenerClass The listenerClass to set.
+ */
+ public void setListenerclass(String listenerClass) {
+ _listenerclass = listenerClass;
+ }
+
+ /**
+ * @return Returns the shortName.
+ */
+ public String getShortname() {
+ return _shortname;
+ }
+
+ /**
+ * @param shortName The shortName to set.
+ */
+ public void setShortname(String shortName) {
+ _shortname = shortName;
+ }
+
+ /**
+ * @return Returns the taglib.
+ */
+ public File getTaglib() {
+ return _taglib;
+ }
+
+ /**
+ * @param taglib The taglib to set.
+ */
+ public void setTaglib(File taglib) {
+ _taglib = taglib;
+ }
+
+ /**
+ * @return Returns the tlibVersion.
+ */
+ public String getTlibversion() {
+ return _tlibversion;
+ }
+
+ /**
+ * @param tlibVersion The tlibVersion to set.
+ */
+ public void setTlibversion(String tlibVersion) {
+ _tlibversion = tlibVersion;
+ }
+
+ /**
+ * @return Returns the uri.
+ */
+ public String getUri() {
+ return _uri;
+ }
+
+ /**
+ * @param uri The uri to set.
+ */
+ public void setUri(String uri) {
+ _uri = uri;
+ }
+
+ /**
+ * @return Returns the validatorClass.
+ */
+ public String getValidatorclass() {
+ return _validatorclass;
+ }
+
+ /**
+ * @param validatorClass The validatorClass to set.
+ */
+ public void setValidatorclass(String validatorClass) {
+ _validatorclass = validatorClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.generator.XMLConfigGenerator#getRootTag()
+ */
+ protected String getRootTag() {
+ //
+ return "taglib";
+ }
+
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ValidatorGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ValidatorGenerator.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ValidatorGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1,105 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.config.ValidatorBean;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+
+/**
+ * This class generates an implementation of a JSF validator
+ *
+ * Uses the validator.vm velocimacro
+ *
+ */
+public class ValidatorGenerator extends InnerGenerator {
+
+ private static final String COMPONENT_FILE_TEMPLATE = "validator.vm";
+ /**
+ * @param task
+ */
+ public ValidatorGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task,log);
+ }
+
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+ context.put("generator",this);
+ // Put common properties
+ for (Iterator iter = config.getValidators().iterator(); iter.hasNext();) {
+ ValidatorBean validator = (ValidatorBean) iter.next();
+ info("Create class file "+validator.getClassname());
+ if (validator.isGenerate()) {
+ context.put("validator", validator);
+ context.put("package", validator.getPackageName());
+ Set<String> importClasses = new HashSet<String>();
+ for (Iterator it = validator.getProperties().iterator(); it
+ .hasNext();) {
+ PropertyBean property = (PropertyBean) it.next();
+ // For non-primitive types, add import declaration.
+ if (!property.isSimpleType() && !property.isExist()) {
+ importClasses.add(property.getClassname());
+ }
+ }
+ importClasses.add(validator.getSuperclass());
+ context.put("imports", importClasses);
+ String resultPath = validator.getClassname().replace('.', '/')
+ + ".java";
+ File javaFile = new File(getDestDir(), resultPath);
+ File javaDir = javaFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (javaFile.exists()) {
+ javaFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(javaFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error generating validator: " + validator.getClassname(), e);
+ }
+ }
+ }
+
+ }
+
+ protected String getDefaultTemplateName() {
+ return COMPONENT_FILE_TEMPLATE;
+ }
+
+}
Added: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ValidatorTagGenerator.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ValidatorTagGenerator.java (rev 0)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ValidatorTagGenerator.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1,138 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.PropertyBean;
+import org.ajax4jsf.builder.config.TagBean;
+import org.ajax4jsf.builder.config.ValidatorBean;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+
+/**
+ * Class implement functionality for generate jsp tags for validators
+ * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * use in ant build.xml :
+ * <jsfgenerator ... >
+ * ....
+ * <tags ... />
+ * ....
+ * </jsfgenerator>
+ * attributes:
+ * {@see com.exadel.vcp.builder.ant.InnerGenerator}
+ *
+ */
+public class ValidatorTagGenerator extends InnerGenerator {
+
+ private static final String TAG_TEMPLATE_NAME = "validatorTag.vm";
+
+ private String _package = null;
+
+ /**
+ * @return Returns the package.
+ */
+ public String getPackage() {
+ return _package;
+ }
+ /**
+ * @param package1 The package to set.
+ */
+ public void setPackage(String package1) {
+ _package = package1;
+ }
+ /**
+ * @param task
+ */
+ public ValidatorTagGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task,log);
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#createFiles(com.exadel.vcp.builder.config.BuilderConfig)
+ */
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ context.put("generator",this);
+ Template template = getTemplate();
+ // Put common properties
+ for (Iterator iter = config.getValidators().iterator(); iter.hasNext();) {
+ ValidatorBean validator = (ValidatorBean) iter.next();
+ TagBean tag = validator.getTag();
+ if ( null != tag && null !=tag.getClassname() && tag.isGenerate()) {
+ info("Create tag class file "+validator.getClassname());
+ context.put("validator", validator);
+
+ context.put("tag", validator.getTag());
+ context.put("package", validator.getTag().getPackageName());
+ Set<String> importClasses = new HashSet<String>();
+ for (Iterator it = validator.getProperties().iterator(); it
+ .hasNext();) {
+ PropertyBean property = (PropertyBean) it.next();
+ // For non-primitive types, add import declaration.
+ if (!property.isSimpleType() && !property.isHidden()) {
+ importClasses.add(property.getClassname());
+ }
+ }
+ importClasses.add(validator.getTag().getSuperclass());
+ context.put("imports", importClasses);
+ String resultPath = validator.getTag().getClassname().replace('.', '/')
+ + ".java";
+ File javaFile = new File(getDestDir(), resultPath);
+ File javaDir = javaFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (javaFile.exists()) {
+ javaFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(javaFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error generating JSP Tag Java file for validator " + validator.getName(), e);
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.exadel.vcp.builder.ant.InnerGenerator#getDefaultTemplateName()
+ */
+ protected String getDefaultTemplateName() {
+ // TODO Auto-generated method stub
+ return TAG_TEMPLATE_NAME;
+ }
+
+}
Modified: trunk/cdk/generator/src/main/resources/META-INF/schema/component-config.dtd
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/schema/component-config.dtd 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/resources/META-INF/schema/component-config.dtd 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,233 +1,249 @@
-<!-- Defenition of component configuration for generator
- PUBLIC-ID "-//AJAX4JSF//CDK Generator config/EN"
- SYSTEM-ID https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd -->
-<!-- Root element for components and renderers -->
-<!ELEMENT components (component*,renderer*,listener*) >
-<!-- Component description with common properties, tags and renderers descriptions -->
-<!ELEMENT component (name,family?,classname?,superclass?,test*,description?,displayname?,icon?,facet*,renderer*,tag?,taghandler?,(include|properties|property)*)>
-
-<!-- components with generate=false not produce component class,
- use for describe superclasses for other components -->
-<!ATTLIST component
- generate (true|false) "true"
- >
-
-<!-- Common component parameters -->
-<!-- Name of component/renderer/property -->
-<!ELEMENT name (#PCDATA)>
-<!-- Component family -->
-<!ELEMENT family (#PCDATA)>
-<!-- Element Description for config files -->
-<!ELEMENT description ANY>
-<!-- Element Dispaly name , for config files -->
-<!ELEMENT displayname ANY>
-<!-- Element icon image , for config files -->
-<!ELEMENT icon (#PCDATA)>
-<!-- component allowed facet name , for config files -->
-<!ELEMENT facet (name,displayname?,description?)>
-<!-- Full name of Java class -->
-<!ELEMENT classname (#PCDATA)>
-<!-- Full name of Java super class -->
-<!ELEMENT superclass (#PCDATA)>
-<!-- Define renderer for this component -->
-<!ELEMENT renderer (name,(classname|template),superclass?,description?,displayname?,icon?,facet?,renderkit?)>
-<!-- Define render kit Id for renderer -->
-<!ELEMENT renderkit (#PCDATA)>
-<!-- Template file name -->
-<!ELEMENT template (#PCDATA)>
-
-<!ATTLIST renderer
- generate (true|false) "false"
- override (true|false) "false"
- >
-
-<!-- Define JSP tag for this component -->
-<!ELEMENT tag (name,classname,superclass?,test*,taglib?,description?,displayname?,icon?)>
-<!ATTLIST tag
- generate (true|false) "true"
- bodyContent (JSP|empty) "JSP"
- >
-
-<!ELEMENT test (classname?,superclassname?)>
-<!--!ELEMENT classname (#PCDATA)-->
-<!ELEMENT superclassname (#PCDATA)>
-
-<!-- Define JSP tag for this component -->
-<!ELEMENT taghandler (name?,classname,superclass?,description?,displayname?,icon?)>
-<!ATTLIST taghandler
- generate (true|false) "false"
- >
-
-<!ELEMENT listener (name,listenerclass,componentclass,eventclass,methodname?,tag?,taghandler?,property*)>
-
-<!ELEMENT listenerclass (#PCDATA)>
-<!ELEMENT eventclass (#PCDATA)>
-<!ELEMENT componentclass (#PCDATA)>
-<!ELEMENT methodname (#PCDATA)>
-
-<!-- Short name of taglib for this tag - for generate set of taglibs in single task -->
-<!ELEMENT taglib (#PCDATA)>
-
-<!-- proprties group for included entity -->
-<!ELEMENT properties ((include|properties|property)*)>
-
-<!-- Define single property for this component -->
-<!ELEMENT property (name,classname?,description?,defaultvalue?,methodargs?,alias*)>
-
-<!-- default value for property -->
-<!ELEMENT defaultvalue (#PCDATA)>
-
-<!-- comma-separated list of method call parameters classes for Method-binded property -->
-<!ELEMENT methodargs (#PCDATA)>
-
-<!-- alias for property in JSP tag -->
-<!ELEMENT alias (#PCDATA)>
-
-<!ATTLIST property
- el (true|false) "true"
- elonly (true|false) "false"
- hidden (true|false) "false"
- exist (true|false) "false"
- raw (true|false) "false"
- existintag (true|false) "false"
- attachedstate (true|false) "false"
- transient (true|false) "false"
- hidden (true|false) "false"
- required (true|false) "false"
- disabled (true|false) "false"
- >
-<!-- include pre-defined properties set -->
-<!ELEMENT include EMPTY >
-<!ATTLIST include
- href CDATA #REQUIRED
->
-
-<!-- pre-defined entities for common components properties -->
-<!ENTITY html_attributes PUBLIC "html_universal_attributes" "entities/html_universal_attributes.ent">
-<!-- pre-defined entities for common component events -->
-<!ENTITY html_events PUBLIC "html_events" "entities/html_events.ent">
-<!-- pre-defined entities for common controls' events -->
-<!ENTITY html_control_events PUBLIC "html_control_events" "entities/html_control_events.ent">
-<!-- -->
-<!ENTITY ajax_region_attributes PUBLIC "ajax_region_attributes" "entities/ajax_region_attributes.ent">
-<!-- -->
-<!ENTITY ajax_component_attributes PUBLIC "ajax_component_attributes" "entities/ajax_component_attributes.ent">
-<!-- -->
-<!ENTITY ajax_output_attributes PUBLIC "ajax_output_attributes" "entities/ajax_output_attributes.ent">
-<!-- -->
-<!ENTITY ajax_dnd_attributes PUBLIC "ajax_dnd_attributes" "entities/ajax_dnd_attributes.ent">
-<!-- -->
-<!ENTITY dropzone_attributes PUBLIC "dropzone_attributes" "entities/dropzone_attributes.ent">
-<!-- -->
-<!ENTITY draggable_attributes PUBLIC "draggable_attributes" "entities/draggable_attributes.ent">
-
-<!-- imported from myfaces -->
-
-<!-- -->
-<!ENTITY validator_min_max_attributes PUBLIC "validator_min_max_attributes" "entities/validator_min_max_attributes.ent">
-<!-- -->
-<!ENTITY ui_component_attributes PUBLIC "ui_component_attributes" "entities/ui_component_attributes.ent">
-<!-- -->
-<!ENTITY ui_parameter_attributes PUBLIC "ui_parameter_attributes" "entities/ui_parameter_attributes.ent">
-<!-- -->
-<!ENTITY ui_for_attribute PUBLIC "ui_for_attribute" "entities/ui_for_attribute.ent">
-<!-- -->
-<!ENTITY ui_select_item_attributes PUBLIC "ui_select_item_attributes" "entities/ui_select_item_attributes.ent">
-<!-- -->
-<!ENTITY ui_select_items_attributes PUBLIC "ui_select_items_attributes" "entities/ui_select_items_attributes.ent">
-<!-- -->
-<!ENTITY html_anchor_attributes PUBLIC "html_anchor_attributes" "entities/html_anchor_attributes.ent">
-<!-- -->
-<!ENTITY html_button_attributes PUBLIC "html_button_attributes" "entities/html_button_attributes.ent">
-<!-- -->
-<!ENTITY html_event_handler_attributes PUBLIC "html_event_handler_attributes" "entities/html_events.ent">
-<!-- -->
-<!ENTITY html_form_attributes PUBLIC "html_form_attributes" "entities/html_form_attributes.ent">
-<!-- -->
-<!ENTITY spec_img_attributes PUBLIC "spec_img_attributes" "entities/spec_img_attributes.ent">
-<!-- -->
-<!ENTITY html_img_attributes PUBLIC "html_img_attributes" "entities/html_img_attributes.ent">
-<!-- -->
-<!ENTITY html_input_attributes PUBLIC "html_input_attributes" "entities/html_input_attributes.ent">
-<!-- -->
-<!ENTITY html_input_checkbox_attributes PUBLIC "html_input_checkbox_attributes" "entities/html_input_checkbox_attributes.ent">
-<!-- -->
-<!ENTITY html_input_radio_attributes PUBLIC "html_input_radio_attributes" "entities/html_input_radio_attributes.ent">
-<!-- -->
-<!ENTITY html_label_attributes PUBLIC "html_label_attributes" "entities/html_label_attributes.ent">
-<!-- -->
-<!ENTITY html_select_attributes PUBLIC "html_select_attributes" "entities/html_select_attributes.ent">
-<!-- -->
-<!ENTITY html_table_attributes PUBLIC "html_table_attributes" "entities/html_table_attributes.ent">
-<!-- -->
-<!ENTITY html_textarea_attributes PUBLIC "html_textarea_attributes" "entities/html_textarea_attributes.ent">
-<!-- -->
-<!ENTITY html_universal_attributes PUBLIC "html_universal_attributes" "entities/html_universal_attributes.ent">
-<!-- -->
-<!ENTITY html_style_attributes PUBLIC "html_style_attributes" "entities/html_style_attributes.ent">
-<!-- -->
-<!ENTITY html_control_attributes PUBLIC "html_control_attributes" "entities/html_control_attributes.ent">
-<!-- -->
-<!ENTITY html_control_events PUBLIC "html_control_events" "entities/html_control_events.ent">
-<!-- -->
-<!ENTITY html_events PUBLIC "html_events" "entities/html_events.ent">
-<!-- -->
-<!ENTITY html_input_events PUBLIC "html_input_events" "entities/html_input_events.ent">
-<!-- -->
-<!ENTITY ui_column_attributes PUBLIC "ui_column_attributes" "entities/ui_column_attributes.ent">
-<!-- -->
-<!ENTITY ui_command_attributes PUBLIC "ui_command_attributes" "entities/ui_command_attributes.ent">
-<!-- -->
-<!ENTITY ui_component_attributes PUBLIC "ui_component_attributes" "entities/ui_component_attributes.ent">
-<!-- -->
-<!ENTITY ui_data_attributes PUBLIC "ui_data_attributes" "entities/ui_data_attributes.ent">
-<!-- -->
-<!ENTITY ui_form_attributes PUBLIC "ui_form_attributes" "entities/ui_form_attributes.ent">
-<!-- -->
-<!ENTITY ui_graphic_attributes PUBLIC "ui_graphic_attributes" "entities/ui_graphic_attributes.ent">
-<!-- -->
-<!ENTITY ui_input_attributes PUBLIC "ui_input_attributes" "entities/ui_input_attributes.ent">
-<!-- -->
-<!ENTITY ui_message_attributes PUBLIC "ui_message_attributes" "entities/ui_message_attributes.ent">
-<!-- -->
-<!ENTITY ui_messages_attributes PUBLIC "ui_messages_attributes" "entities/ui_messages_attributes.ent">
-<!-- -->
-<!ENTITY ui_output_attributes PUBLIC "ui_output_attributes" "entities/ui_output_attributes.ent">
-<!-- -->
-<!ENTITY ui_panel_attributes PUBLIC "ui_panel_attributes" "entities/ui_panel_attributes.ent">
-<!-- -->
-<!ENTITY ui_parameter_attributes PUBLIC "ui_parameter_attributes" "entities/ui_parameter_attributes.ent">
-<!-- -->
-<!ENTITY ui_select_boolean_attributes PUBLIC "ui_select_boolean_attributes" "entities/ui_select_boolean_attributes.ent">
-<!-- -->
-<!ENTITY ui_select_many_attributes PUBLIC "ui_select_many_attributes" "entities/ui_select_many_attributes.ent">
-<!-- -->
-<!ENTITY ui_select_one_attributes PUBLIC "ui_select_one_attributes" "entities/ui_select_one_attributes.ent">
-<!-- -->
-<!ENTITY spec_img_attributes PUBLIC "spec_img_attributes" "entities/spec_img_attributes.ent">
-<!-- -->
-<!ENTITY spec_table_attributes PUBLIC "spec_table_attributes" "entities/spec_table_attributes.ent">
-<!-- -->
-<!ENTITY content_component_attributes PUBLIC "content_component_attributes" "entities/content_component_attributes.ent">
-<!-- -->
-<!ENTITY header_component_attributes PUBLIC "header_component_attributes" "entities/header_component_attributes.ent">
-<!--
-<!ENTITY standard_command_button_attributes PUBLIC "standard_command_button_attributes" "entities/standard_command_button_attributes.ent">
-<!ENTITY standard_command_link_attributes PUBLIC "standard_command_link_attributes" "entities/standard_command_link_attributes.ent">
-<!ENTITY standard_data_table_attributes PUBLIC "standard_data_table_attributes" "entities/standard_data_table_attributes.ent">
-<!ENTITY standard_input_text_attributes PUBLIC "standard_input_text_attributes" "entities/standard_input_text_attributes.ent">
-<!ENTITY standard_input_textarea_attributes PUBLIC "standard_input_textarea_attributes" "entities/standard_input_textarea_attributes.ent">
-<!ENTITY standard_message_attributes PUBLIC "standard_message_attributes" "entities/standard_message_attributes.ent">
-<!ENTITY standard_messages_attributes PUBLIC "standard_messages_attributes" "entities/standard_messages_attributes.ent">
-<!ENTITY standard_output_label_attributes PUBLIC "standard_output_label_attributes" "entities/standard_output_label_attributes.ent">
-<!ENTITY standard_output_text_attributes PUBLIC "standard_output_text_attributes" "entities/standard_output_text_attributes.ent">
-<!ENTITY standard_panel_group_attributes PUBLIC "standard_panel_group_attributes" "entities/standard_panel_group_attributes.ent">
-<!ENTITY standard_panel_grid_attributes PUBLIC "standard_panel_grid_attributes" "entities/standard_panel_grid_attributes.ent">
-<!ENTITY standard_select_boolean_checkbox_attributes PUBLIC "standard_select_boolean_checkbox_attributes" "entities/standard_select_boolean_checkbox_attributes.ent">
-<!ENTITY standard_select_many_checkbox_attributes PUBLIC "standard_select_many_checkbox_attributes" "entities/standard_select_many_checkbox_attributes.ent">
-<!ENTITY standard_select_many_listbox_attributes PUBLIC "standard_select_many_listbox_attributes" "entities/standard_select_many_listbox_attributes.ent">
-<!ENTITY standard_select_many_menu_attributes PUBLIC "standard_select_many_menu_attributes" "entities/standard_select_many_menu_attributes.ent">
-<!ENTITY standard_select_one_listbox_attributes PUBLIC "standard_select_one_listbox_attributes" "entities/standard_select_one_listbox_attributes.ent">
-<!ENTITY standard_select_one_menu_attributes PUBLIC "standard_select_one_menu_attributes" "entities/standard_select_one_menu_attributes.ent">
-<!ENTITY standard_select_one_radio_attributes PUBLIC "standard_select_one_radio_attributes" "entities/standard_select_one_radio_attributes.ent">
+<!-- Defenition of component configuration for generator
+ PUBLIC-ID "-//AJAX4JSF//CDK Generator config/EN"
+ SYSTEM-ID https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd -->
+<!-- Root element for components and renderers -->
+<!ELEMENT components (component*,renderer*,listener*,validator*,converter*) >
+<!-- Component description with common properties, tags and renderers descriptions -->
+<!ELEMENT component (name,family?,classname?,superclass?,test*,description?,displayname?,icon?,facet*,renderer*,tag?,taghandler?,(include|properties|property)*)>
+<!-- Validator description with properties and tags -->
+<!ELEMENT validator (name,classname?,superclass?,test*,description?,displayname?,icon?,tag?,taghandler?,(include|properties|property)*)>
+<!-- Validator description with properties and tags -->
+<!ELEMENT converter (name,classname?,superclass?,test*,description?,displayname?,icon?,tag?,taghandler?,(include|properties|property)*)>
+
+<!-- components with generate=false not produce component class,
+ use for describe superclasses for other components -->
+<!ATTLIST component
+ generate (true|false) "true"
+ >
+
+<!-- validators with generate=false do not generate a class -->
+<!ATTLIST validator
+ generate (true|false) "true"
+ >
+
+<!-- converters with generate=false do not generate a class -->
+<!ATTLIST converter
+ generate (true|false) "true"
+ >
+
+<!-- Common component parameters -->
+<!-- Name of component/renderer/property -->
+<!ELEMENT name (#PCDATA)>
+<!-- Id of the validator/converter -->
+<!ELEMENT id (#PCDATA)>
+<!-- Component family -->
+<!ELEMENT family (#PCDATA)>
+<!-- Element Description for config files -->
+<!ELEMENT description ANY>
+<!-- Element Dispaly name , for config files -->
+<!ELEMENT displayname ANY>
+<!-- Element icon image , for config files -->
+<!ELEMENT icon (#PCDATA)>
+<!-- component allowed facet name , for config files -->
+<!ELEMENT facet (name,displayname?,description?)>
+<!-- Full name of Java class -->
+<!ELEMENT classname (#PCDATA)>
+<!-- Full name of Java super class -->
+<!ELEMENT superclass (#PCDATA)>
+<!-- Define renderer for this component -->
+<!ELEMENT renderer (name,(classname|template),superclass?,description?,displayname?,icon?,facet?,renderkit?)>
+<!-- Define render kit Id for renderer -->
+<!ELEMENT renderkit (#PCDATA)>
+<!-- Template file name -->
+<!ELEMENT template (#PCDATA)>
+
+<!ATTLIST renderer
+ generate (true|false) "false"
+ override (true|false) "false"
+ >
+
+<!-- Define JSP tag for this component -->
+<!ELEMENT tag (name,classname,superclass?,test*,taglib?,description?,displayname?,icon?)>
+<!ATTLIST tag
+ generate (true|false) "true"
+ bodyContent (JSP|empty) "JSP"
+ >
+
+<!ELEMENT test (classname?,superclassname?)>
+<!--!ELEMENT classname (#PCDATA)-->
+<!ELEMENT superclassname (#PCDATA)>
+
+<!-- Define JSP tag for this component -->
+<!ELEMENT taghandler (name?,classname,superclass?,description?,displayname?,icon?)>
+<!ATTLIST taghandler
+ generate (true|false) "false"
+ >
+
+<!ELEMENT listener (name,listenerclass,componentclass,eventclass,methodname?,tag?,taghandler?,property*)>
+
+<!ELEMENT listenerclass (#PCDATA)>
+<!ELEMENT eventclass (#PCDATA)>
+<!ELEMENT componentclass (#PCDATA)>
+<!ELEMENT methodname (#PCDATA)>
+
+<!-- Short name of taglib for this tag - for generate set of taglibs in single task -->
+<!ELEMENT taglib (#PCDATA)>
+
+<!-- proprties group for included entity -->
+<!ELEMENT properties ((include|properties|property)*)>
+
+<!-- Define single property for this component -->
+<!ELEMENT property (name,classname?,description?,defaultvalue?,methodargs?,alias*)>
+
+<!-- default value for property -->
+<!ELEMENT defaultvalue (#PCDATA)>
+
+<!-- comma-separated list of method call parameters classes for Method-binded property -->
+<!ELEMENT methodargs (#PCDATA)>
+
+<!-- alias for property in JSP tag -->
+<!ELEMENT alias (#PCDATA)>
+
+<!ATTLIST property
+ el (true|false) "true"
+ elonly (true|false) "false"
+ hidden (true|false) "false"
+ exist (true|false) "false"
+ raw (true|false) "false"
+ existintag (true|false) "false"
+ attachedstate (true|false) "false"
+ transient (true|false) "false"
+ hidden (true|false) "false"
+ required (true|false) "false"
+ disabled (true|false) "false"
+ >
+<!-- include pre-defined properties set -->
+<!ELEMENT include EMPTY >
+<!ATTLIST include
+ href CDATA #REQUIRED
+>
+
+<!-- pre-defined entities for common components properties -->
+<!ENTITY html_attributes PUBLIC "html_universal_attributes" "entities/html_universal_attributes.ent">
+<!-- pre-defined entities for common component events -->
+<!ENTITY html_events PUBLIC "html_events" "entities/html_events.ent">
+<!-- pre-defined entities for common controls' events -->
+<!ENTITY html_control_events PUBLIC "html_control_events" "entities/html_control_events.ent">
+<!-- -->
+<!ENTITY ajax_region_attributes PUBLIC "ajax_region_attributes" "entities/ajax_region_attributes.ent">
+<!-- -->
+<!ENTITY ajax_component_attributes PUBLIC "ajax_component_attributes" "entities/ajax_component_attributes.ent">
+<!-- -->
+<!ENTITY ajax_output_attributes PUBLIC "ajax_output_attributes" "entities/ajax_output_attributes.ent">
+<!-- -->
+<!ENTITY ajax_dnd_attributes PUBLIC "ajax_dnd_attributes" "entities/ajax_dnd_attributes.ent">
+<!-- -->
+<!ENTITY dropzone_attributes PUBLIC "dropzone_attributes" "entities/dropzone_attributes.ent">
+<!-- -->
+<!ENTITY draggable_attributes PUBLIC "draggable_attributes" "entities/draggable_attributes.ent">
+
+<!-- imported from myfaces -->
+
+<!-- -->
+<!ENTITY validator_min_max_attributes PUBLIC "validator_min_max_attributes" "entities/validator_min_max_attributes.ent">
+<!-- -->
+<!ENTITY ui_component_attributes PUBLIC "ui_component_attributes" "entities/ui_component_attributes.ent">
+<!-- -->
+<!ENTITY ui_parameter_attributes PUBLIC "ui_parameter_attributes" "entities/ui_parameter_attributes.ent">
+<!-- -->
+<!ENTITY ui_for_attribute PUBLIC "ui_for_attribute" "entities/ui_for_attribute.ent">
+<!-- -->
+<!ENTITY ui_select_item_attributes PUBLIC "ui_select_item_attributes" "entities/ui_select_item_attributes.ent">
+<!-- -->
+<!ENTITY ui_select_items_attributes PUBLIC "ui_select_items_attributes" "entities/ui_select_items_attributes.ent">
+<!-- -->
+<!ENTITY html_anchor_attributes PUBLIC "html_anchor_attributes" "entities/html_anchor_attributes.ent">
+<!-- -->
+<!ENTITY html_button_attributes PUBLIC "html_button_attributes" "entities/html_button_attributes.ent">
+<!-- -->
+<!ENTITY html_event_handler_attributes PUBLIC "html_event_handler_attributes" "entities/html_events.ent">
+<!-- -->
+<!ENTITY html_form_attributes PUBLIC "html_form_attributes" "entities/html_form_attributes.ent">
+<!-- -->
+<!ENTITY spec_img_attributes PUBLIC "spec_img_attributes" "entities/spec_img_attributes.ent">
+<!-- -->
+<!ENTITY html_img_attributes PUBLIC "html_img_attributes" "entities/html_img_attributes.ent">
+<!-- -->
+<!ENTITY html_input_attributes PUBLIC "html_input_attributes" "entities/html_input_attributes.ent">
+<!-- -->
+<!ENTITY html_input_checkbox_attributes PUBLIC "html_input_checkbox_attributes" "entities/html_input_checkbox_attributes.ent">
+<!-- -->
+<!ENTITY html_input_radio_attributes PUBLIC "html_input_radio_attributes" "entities/html_input_radio_attributes.ent">
+<!-- -->
+<!ENTITY html_label_attributes PUBLIC "html_label_attributes" "entities/html_label_attributes.ent">
+<!-- -->
+<!ENTITY html_select_attributes PUBLIC "html_select_attributes" "entities/html_select_attributes.ent">
+<!-- -->
+<!ENTITY html_table_attributes PUBLIC "html_table_attributes" "entities/html_table_attributes.ent">
+<!-- -->
+<!ENTITY html_textarea_attributes PUBLIC "html_textarea_attributes" "entities/html_textarea_attributes.ent">
+<!-- -->
+<!ENTITY html_universal_attributes PUBLIC "html_universal_attributes" "entities/html_universal_attributes.ent">
+<!-- -->
+<!ENTITY html_style_attributes PUBLIC "html_style_attributes" "entities/html_style_attributes.ent">
+<!-- -->
+<!ENTITY html_control_attributes PUBLIC "html_control_attributes" "entities/html_control_attributes.ent">
+<!-- -->
+<!ENTITY html_control_events PUBLIC "html_control_events" "entities/html_control_events.ent">
+<!-- -->
+<!ENTITY html_events PUBLIC "html_events" "entities/html_events.ent">
+<!-- -->
+<!ENTITY html_input_events PUBLIC "html_input_events" "entities/html_input_events.ent">
+<!-- -->
+<!ENTITY ui_column_attributes PUBLIC "ui_column_attributes" "entities/ui_column_attributes.ent">
+<!-- -->
+<!ENTITY ui_command_attributes PUBLIC "ui_command_attributes" "entities/ui_command_attributes.ent">
+<!-- -->
+<!ENTITY ui_component_attributes PUBLIC "ui_component_attributes" "entities/ui_component_attributes.ent">
+<!-- -->
+<!ENTITY ui_data_attributes PUBLIC "ui_data_attributes" "entities/ui_data_attributes.ent">
+<!-- -->
+<!ENTITY ui_form_attributes PUBLIC "ui_form_attributes" "entities/ui_form_attributes.ent">
+<!-- -->
+<!ENTITY ui_graphic_attributes PUBLIC "ui_graphic_attributes" "entities/ui_graphic_attributes.ent">
+<!-- -->
+<!ENTITY ui_input_attributes PUBLIC "ui_input_attributes" "entities/ui_input_attributes.ent">
+<!-- -->
+<!ENTITY ui_message_attributes PUBLIC "ui_message_attributes" "entities/ui_message_attributes.ent">
+<!-- -->
+<!ENTITY ui_messages_attributes PUBLIC "ui_messages_attributes" "entities/ui_messages_attributes.ent">
+<!-- -->
+<!ENTITY ui_output_attributes PUBLIC "ui_output_attributes" "entities/ui_output_attributes.ent">
+<!-- -->
+<!ENTITY ui_panel_attributes PUBLIC "ui_panel_attributes" "entities/ui_panel_attributes.ent">
+<!-- -->
+<!ENTITY ui_parameter_attributes PUBLIC "ui_parameter_attributes" "entities/ui_parameter_attributes.ent">
+<!-- -->
+<!ENTITY ui_select_boolean_attributes PUBLIC "ui_select_boolean_attributes" "entities/ui_select_boolean_attributes.ent">
+<!-- -->
+<!ENTITY ui_select_many_attributes PUBLIC "ui_select_many_attributes" "entities/ui_select_many_attributes.ent">
+<!-- -->
+<!ENTITY ui_select_one_attributes PUBLIC "ui_select_one_attributes" "entities/ui_select_one_attributes.ent">
+<!-- -->
+<!ENTITY spec_img_attributes PUBLIC "spec_img_attributes" "entities/spec_img_attributes.ent">
+<!-- -->
+<!ENTITY spec_table_attributes PUBLIC "spec_table_attributes" "entities/spec_table_attributes.ent">
+<!-- -->
+<!ENTITY content_component_attributes PUBLIC "content_component_attributes" "entities/content_component_attributes.ent">
+<!-- -->
+<!ENTITY header_component_attributes PUBLIC "header_component_attributes" "entities/header_component_attributes.ent">
+<!--
+<!ENTITY standard_command_button_attributes PUBLIC "standard_command_button_attributes" "entities/standard_command_button_attributes.ent">
+<!ENTITY standard_command_link_attributes PUBLIC "standard_command_link_attributes" "entities/standard_command_link_attributes.ent">
+<!ENTITY standard_data_table_attributes PUBLIC "standard_data_table_attributes" "entities/standard_data_table_attributes.ent">
+<!ENTITY standard_input_text_attributes PUBLIC "standard_input_text_attributes" "entities/standard_input_text_attributes.ent">
+<!ENTITY standard_input_textarea_attributes PUBLIC "standard_input_textarea_attributes" "entities/standard_input_textarea_attributes.ent">
+<!ENTITY standard_message_attributes PUBLIC "standard_message_attributes" "entities/standard_message_attributes.ent">
+<!ENTITY standard_messages_attributes PUBLIC "standard_messages_attributes" "entities/standard_messages_attributes.ent">
+<!ENTITY standard_output_label_attributes PUBLIC "standard_output_label_attributes" "entities/standard_output_label_attributes.ent">
+<!ENTITY standard_output_text_attributes PUBLIC "standard_output_text_attributes" "entities/standard_output_text_attributes.ent">
+<!ENTITY standard_panel_group_attributes PUBLIC "standard_panel_group_attributes" "entities/standard_panel_group_attributes.ent">
+<!ENTITY standard_panel_grid_attributes PUBLIC "standard_panel_grid_attributes" "entities/standard_panel_grid_attributes.ent">
+<!ENTITY standard_select_boolean_checkbox_attributes PUBLIC "standard_select_boolean_checkbox_attributes" "entities/standard_select_boolean_checkbox_attributes.ent">
+<!ENTITY standard_select_many_checkbox_attributes PUBLIC "standard_select_many_checkbox_attributes" "entities/standard_select_many_checkbox_attributes.ent">
+<!ENTITY standard_select_many_listbox_attributes PUBLIC "standard_select_many_listbox_attributes" "entities/standard_select_many_listbox_attributes.ent">
+<!ENTITY standard_select_many_menu_attributes PUBLIC "standard_select_many_menu_attributes" "entities/standard_select_many_menu_attributes.ent">
+<!ENTITY standard_select_one_listbox_attributes PUBLIC "standard_select_one_listbox_attributes" "entities/standard_select_one_listbox_attributes.ent">
+<!ENTITY standard_select_one_menu_attributes PUBLIC "standard_select_one_menu_attributes" "entities/standard_select_one_menu_attributes.ent">
+<!ENTITY standard_select_one_radio_attributes PUBLIC "standard_select_one_radio_attributes" "entities/standard_select_one_radio_attributes.ent">
-->
\ No newline at end of file
Added: trunk/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm (rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm 2007-04-24 00:51:23 UTC (rev 114)
@@ -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/templates12/converter.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/converter.vm (rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/converter.vm 2007-04-24 00:51:23 UTC (rev 114)
@@ -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/templates12/converterTag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/converterTag.vm (rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/converterTag.vm 2007-04-24 00:51:23 UTC (rev 114)
@@ -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
+ }
+
+}
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/facelets.taglib.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/facelets.taglib.vm 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/facelets.taglib.vm 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,31 +1,55 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE facelet-taglib PUBLIC
- "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
- "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
-<facelet-taglib xmlns="http://java.sun.com/JSF/Facelet">
- <namespace>${taglib.uri}</namespace>
-
-${taglib.includeContent}
-
-#foreach( $component in ${components})
-#if($component.tag)
- <tag>
- <tag-name>${component.tag.name}</tag-name>
- <component>
- <component-type>${component.name}</component-type>
-#if(${component.renderer})
- <renderer-type>
- ${component.renderer.name}
- </renderer-type>
-#end
-#if(${component.taghandler})
- <handler-class>
- ${component.taghandler.classname}
- </handler-class>
-#end
- </component>
-
- </tag>
-#end
-#end
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE facelet-taglib PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
+ "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
+<facelet-taglib xmlns="http://java.sun.com/JSF/Facelet">
+ <namespace>${taglib.uri}</namespace>
+
+${taglib.includeContent}
+
+#foreach( $component in ${components} )
+ #if($component.tag)
+ <tag>
+ <tag-name>${component.tag.name}</tag-name>
+ <component>
+ <component-type>${component.name}</component-type>
+ #if(${component.renderer})
+ <renderer-type>${component.renderer.name}</renderer-type>
+ #end
+ #if(${component.taghandler})
+ <handler-class>${component.taghandler.classname}</handler-class>
+ #end
+ </component>
+ </tag>
+ #end
+#end
+
+#foreach( $validator in ${validators})
+#if($validator.tag)
+ <tag>
+ <tag-name>${validator.tag.name}</tag-name>
+ <validator>
+ <validator-id>${validator.id}</validator-id>
+#if(${validator.taghandler})
+ <handler-class>${validator.taghandler.classname}</handler-class>
+#end
+ </validator>
+ </tag>
+#end
+#end
+
+#foreach( $converter in ${converters} )
+#if($converter.tag)
+ <tag>
+ <tag-name>${converter.tag.name}</tag-name>
+ <converter>
+ <converter-id>${converter.id}</converter-id>
+#if(${converter.taghandler})
+ <handler-class>${converter.taghandler.classname}</handler-class>
+#end
+ </converter>
+ </tag>
+#end
+#end
+
</facelet-taglib>
\ No newline at end of file
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/faces-config.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/faces-config.vm 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/faces-config.vm 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,69 +1,103 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
- "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
-<faces-config>
-
-${facesConfig.includeContent}
-
-#foreach( $component in ${components})
-#if( $component.generate )
- <component>
- #if(${component.description})
- <description>${component.xmlEncodedDescription}</description>
- #end
- #if(${component.displayname})
- <display-name>${component.xmlEncodedDisplayname}</display-name>
- #end
- <component-type>${component.name}</component-type>
- <component-class>${component.classname}</component-class>
-
-#foreach( $facet in $component.facets)
- <facet>
- #if(${facet.description})
- <description>${facet.xmlEncodedDescription}</description>
- #end
- #if(${facet.displayname})
- <display-name>${facet.xmlEncodedDisplayname}</display-name>
- #end
- <facet-name>${facet.name}</facet-name>
- </facet>
-#end
- #if(${component.renderer})
- <component-extension>
- <component-family>${component.family}</component-family>
- <renderer-type>${component.renderer.name}</renderer-type>
- </component-extension>
- #end
- </component>
-#end
-#end
-
-#foreach( $renderkit in $facesConfig.renderKits)
- <render-kit>
- #if(${renderkit.renderkitid})
- <render-kit-id>${renderkit.renderkitid}</render-kit-id>
- #if(${renderkit.renderkitclass})
- <render-kit-class>${renderkit.renderkitclass}</render-kit-class>
- #end
- #end
-#foreach( $component in $components)
- #if($component.renderer)
- #set($rendererClass = $renderkit.rendererClass($component.renderer.classname) )
- #if( $component.renderer.generate || $facesConfig.rendererExists("${rendererClass}"))
- <renderer>
- <component-family>${component.family}</component-family>
- <renderer-type>
- ${component.renderer.name}
- </renderer-type>
- <renderer-class>
- ${rendererClass}
- </renderer-class>
- </renderer>
- #end
- #end
-#end
- </render-kit>
-#end
-
-
-</faces-config>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
+ "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+<faces-config>
+
+${facesConfig.includeContent}
+
+#foreach( $component in ${components})
+#if( $component.generate )
+ <component>
+ #if(${component.description})
+ <description>${component.xmlEncodedDescription}</description>
+ #end
+ #if(${component.displayname})
+ <display-name>${component.xmlEncodedDisplayname}</display-name>
+ #end
+ <component-type>${component.name}</component-type>
+ <component-class>${component.classname}</component-class>
+
+#foreach( $facet in $component.facets)
+ <facet>
+ #if(${facet.description})
+ <description>${facet.xmlEncodedDescription}</description>
+ #end
+ #if(${facet.displayname})
+ <display-name>${facet.xmlEncodedDisplayname}</display-name>
+ #end
+ <facet-name>${facet.name}</facet-name>
+ </facet>
+#end
+ #if(${component.renderer})
+ <component-extension>
+ <component-family>${component.family}</component-family>
+ <renderer-type>${component.renderer.name}</renderer-type>
+ </component-extension>
+ #end
+ </component>
+#end
+#end
+
+#foreach( $validator in ${validators})
+ #if( $validator.generate )
+ <validator>
+ #if(${validator.description})
+ <description>${validator.xmlEncodedDescription}</description>
+ #end
+ #if(${validator.displayname})
+ <display-name>${validator.xmlEncodedDisplayname}</display-name>
+ #end
+ <validator-id>${validator.id}</validator-id>
+ <validator-class>${validator.classname}</validator-class>
+ </validator>
+ #end
+#end
+
+#foreach( $converter in ${converters})
+ #if( $converter.generate )
+ <converter>
+ #if(${converter.description})
+ <description>${converter.xmlEncodedDescription}</description>
+ #end
+ #if(${converter.displayname})
+ <display-name>${converter.xmlEncodedDisplayname}</display-name>
+ #end
+ #if(${converter.forClass})
+ <converter-for-class>${converter.forClass}</converter-for-class>
+ #elseif(${converter.id})
+ <converter-id>${converter.id}</converter-id>
+ #end
+ <converter-class>${converter.classname}</converter-class>
+ </converter>
+ #end
+#end
+
+#foreach( $renderkit in $facesConfig.renderKits)
+ <render-kit>
+ #if(${renderkit.renderkitid})
+ <render-kit-id>${renderkit.renderkitid}</render-kit-id>
+ #if(${renderkit.renderkitclass})
+ <render-kit-class>${renderkit.renderkitclass}</render-kit-class>
+ #end
+ #end
+#foreach( $component in $components)
+ #if($component.renderer)
+ #set($rendererClass = $renderkit.rendererClass($component.renderer.classname) )
+ #if( $component.renderer.generate || $facesConfig.rendererExists("${rendererClass}"))
+ <renderer>
+ <component-family>${component.family}</component-family>
+ <renderer-type>
+ ${component.renderer.name}
+ </renderer-type>
+ <renderer-class>
+ ${rendererClass}
+ </renderer-class>
+ </renderer>
+ #end
+ #end
+#end
+ </render-kit>
+#end
+
+
+</faces-config>
Deleted: trunk/cdk/generator/src/main/resources/META-INF/templates12/tag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/tag.vm 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/tag.vm 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,154 +0,0 @@
-/**
- * GENERATED FILE - DO NOT EDIT
- *
- */
-package ${tag.packageName};
-
-#foreach($import in $imports)
-import $import ;
-#end
-import javax.faces.component.UIComponent;
-import ${component.classname};
-
-/**
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/26 20:48:51 $
- *
- */
-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
- }
-
-}
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/taglib.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/taglib.vm 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/taglib.vm 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,54 +1,132 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
- "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
-<taglib>
- <tlib-version>${taglib.tlibversion}</tlib-version>
- <jsp-version>${taglib.jspversion}</jsp-version>
-#if(${taglib.shortname})
- <short-name>${taglib.shortname}</short-name>
-#end
- <uri>${taglib.uri}</uri>
-#if(${taglib.description})
- <description>${taglib.description}</description>
-#end
-${taglib.includeContent}
-
-#foreach( $component in ${components})
- #if($component.tag)
- <tag>
- <name>${component.tag.name}</name>
- <tag-class>${component.tag.classname}</tag-class>
- <body-content>${component.tag.bodyContent}</body-content>
- #if(${component.tag.displayname})
- <display-name>${component.tag.xmlEncodedDisplayname}</display-name>
- #elseif(${component.displayname})
- <display-name>${component.xmlEncodedDisplayname}</display-name>
- #end
- #if(${component.tag.description})
- <description>${component.tag.xmlEncodedDescription}</description>
- #else
- <description>${component.xmlEncodedDescription}</description>
- #end
- #foreach( $prop in ${component.properties} )
- #if( !${prop.hidden} && !${prop.disabled} )
- <attribute>
- <name>${prop.name}</name>
- #if(${prop.required})
- <required>true</required>
- #end
- <rtexprvalue>false</rtexprvalue>
- <description>${prop.xmlEncodedDescription}</description>
- </attribute>
- #if( $prop.alias )
- <attribute>
- <name>${prop.alias}</name>
- <rtexprvalue>false</rtexprvalue>
- <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
- </attribute>
- #end
- #end
- #end
-</tag>
-#end
-#end
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
+ "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
+<taglib>
+ <tlib-version>${taglib.tlibversion}</tlib-version>
+ <jsp-version>${taglib.jspversion}</jsp-version>
+#if(${taglib.shortname})
+ <short-name>${taglib.shortname}</short-name>
+#end
+ <uri>${taglib.uri}</uri>
+#if(${taglib.description})
+ <description>${taglib.description}</description>
+#end
+${taglib.includeContent}
+
+#foreach( $component in ${components})
+ #if($component.tag)
+ <tag>
+ <name>${component.tag.name}</name>
+ <tag-class>${component.tag.classname}</tag-class>
+ <body-content>${component.tag.bodyContent}</body-content>
+ #if(${component.tag.displayname})
+ <display-name>${component.tag.xmlEncodedDisplayname}</display-name>
+ #elseif(${component.displayname})
+ <display-name>${component.xmlEncodedDisplayname}</display-name>
+ #end
+ #if(${component.tag.description})
+ <description>${component.tag.xmlEncodedDescription}</description>
+ #else
+ <description>${component.xmlEncodedDescription}</description>
+ #end
+ #foreach( $prop in ${component.properties} )
+ #if( !${prop.hidden} && !${prop.disabled} )
+ <attribute>
+ <name>${prop.name}</name>
+ #if(${prop.required})
+ <required>true</required>
+ #end
+ <rtexprvalue>false</rtexprvalue>
+ <description>${prop.xmlEncodedDescription}</description>
+ </attribute>
+ #if( $prop.alias )
+ <attribute>
+ <name>${prop.alias}</name>
+ <rtexprvalue>false</rtexprvalue>
+ <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
+ </attribute>
+ #end
+ #end
+ #end
+</tag>
+#end
+#end
+
+#foreach( $validator in ${validators})
+ #if($validator.tag)
+ <tag>
+ <name>${validator.tag.name}</name>
+ <tag-class>${validator.tag.classname}</tag-class>
+ <body-content>${validator.tag.bodyContent}</body-content>
+ #if(${validator.tag.displayname})
+ <display-name>${validator.tag.xmlEncodedDisplayname}</display-name>
+ #elseif(${validator.displayname})
+ <display-name>${validator.xmlEncodedDisplayname}</display-name>
+ #end
+ #if(${validator.tag.description})
+ <description>${validator.tag.xmlEncodedDescription}</description>
+ #else
+ <description>${validator.xmlEncodedDescription}</description>
+ #end
+ #foreach( $prop in ${validator.properties} )
+ #if( !${prop.hidden} && !${prop.disabled} )
+ <attribute>
+ <name>${prop.name}</name>
+ #if(${prop.required})
+ <required>true</required>
+ #end
+ <rtexprvalue>false</rtexprvalue>
+ <description>${prop.xmlEncodedDescription}</description>
+ </attribute>
+ #if( $prop.alias )
+ <attribute>
+ <name>${prop.alias}</name>
+ <rtexprvalue>false</rtexprvalue>
+ <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
+ </attribute>
+ #end
+ #end
+ #end
+</tag>
+#end
+#end
+
+#foreach( $converter in ${converters})
+ #if($converter.tag)
+ <tag>
+ <name>${converter.tag.name}</name>
+ <tag-class>${converter.tag.classname}</tag-class>
+ <body-content>${converter.tag.bodyContent}</body-content>
+ #if(${converter.tag.displayname})
+ <display-name>${converter.tag.xmlEncodedDisplayname}</display-name>
+ #elseif(${converter.displayname})
+ <display-name>${coonverter.xmlEncodedDisplayname}</display-name>
+ #end
+ #if(${converter.tag.description})
+ <description>${converter.tag.xmlEncodedDescription}</description>
+ #else
+ <description>${converter.xmlEncodedDescription}</description>
+ #end
+ #foreach( $prop in ${converter.properties} )
+ #if( !${prop.hidden} && !${prop.disabled} )
+ <attribute>
+ <name>${prop.name}</name>
+ #if(${prop.required})
+ <required>true</required>
+ #end
+ <rtexprvalue>false</rtexprvalue>
+ <description>${prop.xmlEncodedDescription}</description>
+ </attribute>
+ #if( $prop.alias )
+ <attribute>
+ <name>${prop.alias}</name>
+ <rtexprvalue>false</rtexprvalue>
+ <description>Alias for ${prop.name} : ${prop.xmlEncodedDescription}</description>
+ </attribute>
+ #end
+ #end
+ #end
+</tag>
+#end
+#end
</taglib>
\ No newline at end of file
Added: trunk/cdk/generator/src/main/resources/META-INF/templates12/validatorTag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/validatorTag.vm (rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/validatorTag.vm 2007-04-24 00:51:23 UTC (rev 114)
@@ -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/maven-cdk-plugin/bin/.svnignore
===================================================================
--- trunk/cdk/maven-cdk-plugin/bin/.svnignore (rev 0)
+++ trunk/cdk/maven-cdk-plugin/bin/.svnignore 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1 @@
+target
Added: trunk/cdk/maven-cdk-plugin/bin/pom.xml
===================================================================
--- trunk/cdk/maven-cdk-plugin/bin/pom.xml (rev 0)
+++ trunk/cdk/maven-cdk-plugin/bin/pom.xml 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1,56 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>cdk</artifactId>
+ <groupId>org.ajax4jsf</groupId>
+ <version>1.1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.ajax4jsf.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <name>Maven plugin for JSF components code generation</name>
+ <url>http://labs.jboss.com/wiki/Ajax4jsf/cdk/maven-cdk-plugin/</url>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-archiver</artifactId>
+ <version>2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>file-management</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-velocity</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ajax4jsf.cdk</groupId>
+ <artifactId>generator</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/cdk/maven-cdk-plugin/bin/src/site/site.xml
===================================================================
--- trunk/cdk/maven-cdk-plugin/bin/src/site/site.xml (rev 0)
+++ trunk/cdk/maven-cdk-plugin/bin/src/site/site.xml 2007-04-24 00:51:23 UTC (rev 114)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="JSF Components development kit">
+ <bannerLeft>
+ <name>JSF Component generator Maven plugin</name>
+ <src>images/exadel_logo.jpg</src>
+ <href>http://ajax4jsf.org/cdk</href>
+ </bannerLeft>
+ <bannerRight>
+ <src>http://maven.apache.org/images/maven-small.gif</src>
+ </bannerRight>
+ <publishDate position="navigation-bottom" format="MM-dd-yy"/>
+ <body>
+ <links>
+ <item name="JSF" href="https://javaserverfaces.dev.java.net/" />
+ <item name="Maven 2" href="http://maven.apache.org/maven2/"/>
+ </links>
+
+ <menu name="JSF CDK">
+ <item name="Introduction" href="index.html"/>
+ <item name="Usage" href="usage.html"/>
+ </menu>
+ <menu ref="parent"/>
+ <menu ref="reports" />
+ </body>
+</project>
\ No newline at end of file
Modified: trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateMojo.java
===================================================================
--- trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateMojo.java 2007-04-23 23:19:40 UTC (rev 113)
+++ trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateMojo.java 2007-04-24 00:51:23 UTC (rev 114)
@@ -1,276 +1,294 @@
-/**
- * License Agreement.
- *
- * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.builder.mojo;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ParsingException;
-import org.ajax4jsf.builder.generator.ComponentGenerator;
-import org.ajax4jsf.builder.generator.FaceletsTaglibGenerator;
-import org.ajax4jsf.builder.generator.FacesConfigGenerator;
-import org.ajax4jsf.builder.generator.GeneratorException;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.generator.ListenerGenerator;
-import org.ajax4jsf.builder.generator.RenderKitBean;
-import org.ajax4jsf.builder.generator.RendererGenerator;
-import org.ajax4jsf.builder.generator.ResourcesConfigGenerator;
-import org.ajax4jsf.builder.generator.TagGenerator;
-import org.ajax4jsf.builder.generator.TagHandlerGenerator;
-import org.ajax4jsf.builder.generator.TaglibGenerator;
-import org.ajax4jsf.builder.maven.MavenLogger;
-import org.ajax4jsf.builder.velocity.BuilderContext;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.Template;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
-
-/**
- * This plugin geterate JSF components and renderers source code, as well as
- * configuration files.
- *
- * @author shura
- * @goal generate
- * @requiresDependencyResolution compile
- * @phase generate-sources
- * @execute phase="compile"
- */
-public class GenerateMojo extends AbstractCDKMojo implements
- JSFGeneratorConfiguration {
-
- /**
- * Project executed by first compile lifecycle.
- *
- * @parameter expression="${executedProject}"
- * @readonly
- */
- protected MavenProject executedProject;
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.maven.plugin.Mojo#execute()
- */
- public void execute() throws MojoExecutionException, MojoFailureException {
- getLog().debug("GenerateMojo components");
- if (null != executedProject) {
- Taglib taglib = checkLibraryConfig();
- // compile goal executed
- try {
- // Parse config files.
- ClassLoader generatiorLoader = createProjectClassLoader(executedProject);
- BuilderConfig config = createConfig(generatiorLoader);
- MavenLogger mavenLogger = new MavenLogger(getLog());
- // TODO - parse sources by qdox for JavaDoc comments ?
- // GenerateMojo components.
- ComponentGenerator compGenerator = new ComponentGenerator(this,
- mavenLogger);
- compGenerator.createFiles(config);
- // GenerateMojo renderers
- RendererGenerator rendererGenerator = new RendererGenerator(
- this, mavenLogger);
- rendererGenerator.setSrcDir(templatesDirectory);
- rendererGenerator.createFiles(config);
- // GenerateMojo component test
-/*
- ComponentTestGenerator componentTestGenerator = new ComponentTestGenerator(this, mavenLogger);
- componentTestGenerator.setDestDir(outputTestsDirectory);
- componentTestGenerator.createFiles(config);
-*/
- // GenerateMojo tags
- TagGenerator tagGenerator = new TagGenerator(this, mavenLogger);
- tagGenerator.createFiles(config);
-
- // GenerateMojo tag test
-/*
- TagTestGenerator tagTestGenerator = new TagTestGenerator(this, mavenLogger);
- tagTestGenerator.setDestDir(outputTestsDirectory);
- tagTestGenerator.createFiles(config);
-*/
- // GenerateMojo tag handlers
- TagHandlerGenerator tagHandlerGenerator = new TagHandlerGenerator(
- this, mavenLogger);
- tagHandlerGenerator.createFiles(config);
- //Generate listeners
- ListenerGenerator listenerGenerator = new ListenerGenerator(this, mavenLogger);
- listenerGenerator.createFiles(config);
-
- JSFGeneratorConfiguration resourcesConfiguration = new JSFGeneratorConfiguration() {
-
- public ClassLoader getClassLoader() {
- return createProjectClassLoader(executedProject);
- }
-
- public File getDestDir() {
- return outputResourcesDirectory;
- }
-
- public String getKey() {
- return key;
- }
-
- public Template getTemplate(String name) throws GeneratorException {
- return GenerateMojo.this.getTemplate(name);
- }
-
- public String getTemplatesPath() {
- return GenerateMojo.this.getTemplatesPath();
- }
-
- };
- // GenerateMojo faces-config
- FacesConfigGenerator configGenerator = new FacesConfigGenerator(
- resourcesConfiguration, mavenLogger);
- configGenerator.setInclude(facesConfigInclude);
- configGenerator.setFacesconfig(new File(
- outputResourcesDirectory, "META-INF/faces-config.xml"));
- RenderKitBean renderKitBean = configGenerator.createRenderKit();
- renderKitBean.setRenderkitid("HTML_BASIC");
- configGenerator.createFiles(config);
- // GenerateMojo JSP taglib
- if (null != taglib) {
- TaglibGenerator taglibGenerator = new TaglibGenerator(
- resourcesConfiguration, mavenLogger);
- taglibGenerator.setUri(taglib.getUri());
- taglibGenerator.setShortname(taglib.getShortName());
- taglibGenerator.setListenerclass(taglib.getListenerClass());
- taglibGenerator.setDisplayname(taglib.getDisplayName());
- taglibGenerator.setListenerclass(taglib.getListenerClass());
- taglibGenerator.setValidatorclass(taglib.getValidatorClass());
- taglibGenerator.setTlibversion(taglib.getTlibVersion());
- taglibGenerator.setJspversion(taglib.getJspVersion());
- taglibGenerator.setInclude(taglibInclude);
- taglibGenerator.setTaglib(new File(
- outputResourcesDirectory, "META-INF/"+taglib.getShortName()
- + ".tld"));
- taglibGenerator.createFiles(config);
- // GenerateMojo Facelets taglib
- FaceletsTaglibGenerator faceletsTaglibGenerator = new FaceletsTaglibGenerator(
- resourcesConfiguration, mavenLogger);
- faceletsTaglibGenerator.setUri(taglib.getUri());
- faceletsTaglibGenerator.setShortname(taglib.getShortName());
- faceletsTaglibGenerator.setInclude(taglibInclude);
- faceletsTaglibGenerator.setTaglib(new File(
- outputResourcesDirectory, "META-INF/"+taglib.getShortName()
- + ".taglib.xml"));
- faceletsTaglibGenerator.createFiles(config);
- }
-
- if (Boolean.getBoolean("generateResourcesConfig")) {
-
- // Generate resources configuration file resources-config.xml
- // for all images/scripts/css...
- ResourcesConfigGenerator resourcesConfigGenerator = new ResourcesConfigGenerator(resourcesConfiguration, mavenLogger);
- resourcesConfigGenerator.setTemplates(templatesDirectory);
- resourcesConfigGenerator.setResourcesConfig(new File(
- outputResourcesDirectory, "META-INF/resources-config.xml"));
- resourcesConfigGenerator.createFiles(config);
- }
-
- // Add generated sources and resources to project
- project.addCompileSourceRoot(outputJavaDirectory.getPath());
-// project.addCompileSourceRoot(outputTestsDirectory.getPath());
-
- Resource resource = new Resource();
- resource.setDirectory(outputResourcesDirectory.getPath());
-// resource.setTargetPath("META-INF");
- project.addResource(resource);
- } catch (Exception e) {
- getLog().error("Error on generate component", e);
- throw new MojoExecutionException(
- "Error in component generation", e);
- }
- }
-
- }
-
- protected BuilderConfig createConfig(ClassLoader generatiorLoader)
- throws ParsingException {
- BuilderConfig builderConfig = new BuilderConfig(generatiorLoader,
- new MavenLogger(getLog()));
- // Get all *.xml config files
- FilenameFilter filter = new FilenameFilter() {
-
- public boolean accept(File dir, String name) {
-
- return name.toLowerCase().endsWith(".xml");
- }
-
- };
- File[] files = componentConfigDirectory.listFiles(filter);
- if (null == files) {
- throw new ParsingException("No config files found");
- }
- for (int i = 0; i < files.length; i++) {
- builderConfig.parseConfig(files[i]);
- }
- builderConfig.checkComopnentProperties();
- return builderConfig;
- }
-
- public File getDestDir() {
- // TODO Auto-generated method stub
- return outputJavaDirectory;
- }
-
- public String getKey() {
- // TODO Auto-generated method stub
- return key;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.builder.generator.JSFGeneratorConfiguration#getClassLoader()
- */
- public ClassLoader getClassLoader() {
- return createProjectClassLoader(executedProject);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.JSFGeneratorConfiguration#getTemplate(java.lang.String)
- */
- public Template getTemplate(String name) throws GeneratorException {
- // TODO Auto-generated method stub
- try {
- return this.velocity.getEngine().getTemplate(name);
- } catch (ResourceNotFoundException e) {
- throw new GeneratorException(e.getLocalizedMessage());
- } catch (ParseErrorException e) {
- throw new GeneratorException(e.getLocalizedMessage());
- } catch (Exception e) {
- throw new GeneratorException(e.getLocalizedMessage());
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.JSFGeneratorConfiguration#getTemplatesPath()
- */
- public String getTemplatesPath() {
- return Library.JSF12.equals(library.getJsfVersion())?BuilderContext.TEMPLATES12_PATH:BuilderContext.TEMPLATES_PATH;
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.builder.mojo;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ParsingException;
+import org.ajax4jsf.builder.generator.ComponentGenerator;
+import org.ajax4jsf.builder.generator.ConverterGenerator;
+import org.ajax4jsf.builder.generator.ConverterTagGenerator;
+import org.ajax4jsf.builder.generator.FaceletsTaglibGenerator;
+import org.ajax4jsf.builder.generator.FacesConfigGenerator;
+import org.ajax4jsf.builder.generator.GeneratorException;
+import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
+import org.ajax4jsf.builder.generator.ListenerGenerator;
+import org.ajax4jsf.builder.generator.RenderKitBean;
+import org.ajax4jsf.builder.generator.RendererGenerator;
+import org.ajax4jsf.builder.generator.ResourcesConfigGenerator;
+import org.ajax4jsf.builder.generator.ComponentTagGenerator;
+import org.ajax4jsf.builder.generator.TagHandlerGenerator;
+import org.ajax4jsf.builder.generator.TaglibGenerator;
+import org.ajax4jsf.builder.generator.ValidatorGenerator;
+import org.ajax4jsf.builder.generator.ValidatorTagGenerator;
+import org.ajax4jsf.builder.maven.MavenLogger;
+import org.ajax4jsf.builder.velocity.BuilderContext;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.Template;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+
+/**
+ * This plugin geterate JSF components and renderers source code, as well as
+ * configuration files.
+ *
+ * @author shura
+ * @goal generate
+ * @requiresDependencyResolution compile
+ * @phase generate-sources
+ * @execute phase="compile"
+ */
+public class GenerateMojo extends AbstractCDKMojo implements
+ JSFGeneratorConfiguration {
+
+ /**
+ * Project executed by first compile lifecycle.
+ *
+ * @parameter expression="${executedProject}"
+ * @readonly
+ */
+ protected MavenProject executedProject;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().debug("GenerateMojo components");
+ if (null != executedProject) {
+ Taglib taglib = checkLibraryConfig();
+ // compile goal executed
+ try {
+ // Parse config files.
+ ClassLoader generatiorLoader = createProjectClassLoader(executedProject);
+ BuilderConfig config = createConfig(generatiorLoader);
+ MavenLogger mavenLogger = new MavenLogger(getLog());
+ // TODO - parse sources by qdox for JavaDoc comments ?
+ // GenerateMojo components.
+ ComponentGenerator compGenerator = new ComponentGenerator(this,
+ mavenLogger);
+ compGenerator.createFiles(config);
+ // GenerateMojo validators
+ ValidatorGenerator validatorGenerator = new ValidatorGenerator(this, mavenLogger);
+ validatorGenerator.createFiles(config);
+ // GenerateMojo converters
+ ConverterGenerator converterGenerator = new ConverterGenerator(this, mavenLogger);
+ converterGenerator.createFiles(config);
+ // GenerateMojo renderers
+ RendererGenerator rendererGenerator = new RendererGenerator(
+ this, mavenLogger);
+ rendererGenerator.setSrcDir(templatesDirectory);
+ rendererGenerator.createFiles(config);
+ // GenerateMojo component test
+/*
+ ComponentTestGenerator componentTestGenerator = new ComponentTestGenerator(this, mavenLogger);
+ componentTestGenerator.setDestDir(outputTestsDirectory);
+ componentTestGenerator.createFiles(config);
+*/
+ // GenerateMojo tags
+ ComponentTagGenerator componentTagGenerator = new ComponentTagGenerator(this, mavenLogger);
+ componentTagGenerator.createFiles(config);
+
+// GenerateMojo tags for validators
+ ValidatorTagGenerator validatorTagGenerator = new ValidatorTagGenerator(this, mavenLogger);
+ validatorTagGenerator.createFiles(config);
+
+// GenerateMojo tags for converters
+ ConverterTagGenerator converterTagGenerator = new ConverterTagGenerator(this, mavenLogger);
+ converterTagGenerator.createFiles(config);
+
+ // GenerateMojo tag test
+/*
+ TagTestGenerator tagTestGenerator = new TagTestGenerator(this, mavenLogger);
+ tagTestGenerator.setDestDir(outputTestsDirectory);
+ tagTestGenerator.createFiles(config);
+*/
+ // GenerateMojo tag handlers
+ TagHandlerGenerator tagHandlerGenerator = new TagHandlerGenerator(
+ this, mavenLogger);
+ tagHandlerGenerator.createFiles(config);
+ //Generate listeners
+ ListenerGenerator listenerGenerator = new ListenerGenerator(this, mavenLogger);
+ listenerGenerator.createFiles(config);
+
+ JSFGeneratorConfiguration resourcesConfiguration = new JSFGeneratorConfiguration() {
+
+ public ClassLoader getClassLoader() {
+ return createProjectClassLoader(executedProject);
+ }
+
+ public File getDestDir() {
+ return outputResourcesDirectory;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public Template getTemplate(String name) throws GeneratorException {
+ return GenerateMojo.this.getTemplate(name);
+ }
+
+ public String getTemplatesPath() {
+ return GenerateMojo.this.getTemplatesPath();
+ }
+
+ };
+ // GenerateMojo faces-config
+ FacesConfigGenerator configGenerator = new FacesConfigGenerator(
+ resourcesConfiguration, mavenLogger);
+ configGenerator.setInclude(facesConfigInclude);
+ configGenerator.setFacesconfig(new File(
+ outputResourcesDirectory, "META-INF/faces-config.xml"));
+ RenderKitBean renderKitBean = configGenerator.createRenderKit();
+ renderKitBean.setRenderkitid("HTML_BASIC");
+ configGenerator.createFiles(config);
+ // GenerateMojo JSP taglib
+ if (null != taglib) {
+ TaglibGenerator taglibGenerator = new TaglibGenerator(
+ resourcesConfiguration, mavenLogger);
+ taglibGenerator.setUri(taglib.getUri());
+ taglibGenerator.setShortname(taglib.getShortName());
+ taglibGenerator.setListenerclass(taglib.getListenerClass());
+ taglibGenerator.setDisplayname(taglib.getDisplayName());
+ taglibGenerator.setListenerclass(taglib.getListenerClass());
+ taglibGenerator.setValidatorclass(taglib.getValidatorClass());
+ taglibGenerator.setTlibversion(taglib.getTlibVersion());
+ taglibGenerator.setJspversion(taglib.getJspVersion());
+ taglibGenerator.setInclude(taglibInclude);
+ taglibGenerator.setTaglib(new File(
+ outputResourcesDirectory, "META-INF/"+taglib.getShortName()
+ + ".tld"));
+ taglibGenerator.createFiles(config);
+ // GenerateMojo Facelets taglib
+ FaceletsTaglibGenerator faceletsTaglibGenerator = new FaceletsTaglibGenerator(
+ resourcesConfiguration, mavenLogger);
+ faceletsTaglibGenerator.setUri(taglib.getUri());
+ faceletsTaglibGenerator.setShortname(taglib.getShortName());
+ faceletsTaglibGenerator.setInclude(taglibInclude);
+ faceletsTaglibGenerator.setTaglib(new File(
+ outputResourcesDirectory, "META-INF/"+taglib.getShortName()
+ + ".taglib.xml"));
+ faceletsTaglibGenerator.createFiles(config);
+ }
+
+ if (Boolean.getBoolean("generateResourcesConfig")) {
+
+ // Generate resources configuration file resources-config.xml
+ // for all images/scripts/css...
+ ResourcesConfigGenerator resourcesConfigGenerator = new ResourcesConfigGenerator(resourcesConfiguration, mavenLogger);
+ resourcesConfigGenerator.setTemplates(templatesDirectory);
+ resourcesConfigGenerator.setResourcesConfig(new File(
+ outputResourcesDirectory, "META-INF/resources-config.xml"));
+ resourcesConfigGenerator.createFiles(config);
+ }
+
+ // Add generated sources and resources to project
+ project.addCompileSourceRoot(outputJavaDirectory.getPath());
+// project.addCompileSourceRoot(outputTestsDirectory.getPath());
+
+ Resource resource = new Resource();
+ resource.setDirectory(outputResourcesDirectory.getPath());
+// resource.setTargetPath("META-INF");
+ project.addResource(resource);
+ } catch (Exception e) {
+ getLog().error("Error on generate component", e);
+ throw new MojoExecutionException(
+ "Error in component generation", e);
+ }
+ }
+
+ }
+
+ protected BuilderConfig createConfig(ClassLoader generatiorLoader)
+ throws ParsingException {
+ BuilderConfig builderConfig = new BuilderConfig(generatiorLoader,
+ new MavenLogger(getLog()));
+ // Get all *.xml config files
+ FilenameFilter filter = new FilenameFilter() {
+
+ public boolean accept(File dir, String name) {
+
+ return name.toLowerCase().endsWith(".xml");
+ }
+
+ };
+ File[] files = componentConfigDirectory.listFiles(filter);
+ if (null == files) {
+ throw new ParsingException("No config files found");
+ }
+ for (int i = 0; i < files.length; i++) {
+ builderConfig.parseConfig(files[i]);
+ }
+ builderConfig.checkComopnentProperties();
+ return builderConfig;
+ }
+
+ public File getDestDir() {
+ // TODO Auto-generated method stub
+ return outputJavaDirectory;
+ }
+
+ public String getKey() {
+ // TODO Auto-generated method stub
+ return key;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.builder.generator.JSFGeneratorConfiguration#getClassLoader()
+ */
+ public ClassLoader getClassLoader() {
+ return createProjectClassLoader(executedProject);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.generator.JSFGeneratorConfiguration#getTemplate(java.lang.String)
+ */
+ public Template getTemplate(String name) throws GeneratorException {
+ // TODO Auto-generated method stub
+ try {
+ return this.velocity.getEngine().getTemplate(name);
+ } catch (ResourceNotFoundException e) {
+ throw new GeneratorException(e.getLocalizedMessage());
+ } catch (ParseErrorException e) {
+ throw new GeneratorException(e.getLocalizedMessage());
+ } catch (Exception e) {
+ throw new GeneratorException(e.getLocalizedMessage());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.builder.generator.JSFGeneratorConfiguration#getTemplatesPath()
+ */
+ public String getTemplatesPath() {
+ return Library.JSF12.equals(library.getJsfVersion())?BuilderContext.TEMPLATES12_PATH:BuilderContext.TEMPLATES_PATH;
+ }
+
+}
17 years, 8 months
JBoss Ajax4JSF SVN: r113 - in trunk/framework/src/main/javascript: dnd and 1 other directories.
by ajax4jsf-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-04-23 19:19:40 -0400 (Mon, 23 Apr 2007)
New Revision: 113
Modified:
trunk/framework/src/main/javascript/ajaxjsf/JSFAJAX.js
trunk/framework/src/main/javascript/ajaxjsf/epilog.js
trunk/framework/src/main/javascript/ajaxjsf/prolog.js
trunk/framework/src/main/javascript/dnd/epilog.js
trunk/framework/src/main/javascript/dnd/prolog.js
trunk/framework/src/main/javascript/prototype/epilog.js
trunk/framework/src/main/javascript/prototype/prolog.js
Log:
remove ( temporary ) checks for a scruipt loading
Modified: trunk/framework/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-04-23 14:43:03 UTC (rev 112)
+++ trunk/framework/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-04-23 23:19:40 UTC (rev 113)
@@ -13,7 +13,7 @@
/**
* XMLHttp transport class - incapsulate most of client-specifiv functions for call server requests.
*/
- A4J.AJAX.XMLHttpRequest = function(query){
+A4J.AJAX.XMLHttpRequest = function(query){
this._query = query;
};
Modified: trunk/framework/src/main/javascript/ajaxjsf/epilog.js
===================================================================
--- trunk/framework/src/main/javascript/ajaxjsf/epilog.js 2007-04-23 14:43:03 UTC (rev 112)
+++ trunk/framework/src/main/javascript/ajaxjsf/epilog.js 2007-04-23 23:19:40 UTC (rev 113)
@@ -1,4 +1,4 @@
/*
* final trail for ajax jsf library
*/
- }
\ No newline at end of file
+// }
\ No newline at end of file
Modified: trunk/framework/src/main/javascript/ajaxjsf/prolog.js
===================================================================
--- trunk/framework/src/main/javascript/ajaxjsf/prolog.js 2007-04-23 14:43:03 UTC (rev 112)
+++ trunk/framework/src/main/javascript/ajaxjsf/prolog.js 2007-04-23 23:19:40 UTC (rev 113)
@@ -3,4 +3,4 @@
*/
if (!window.A4J) { window.A4J= {};}
-if(!A4J.AJAX){
+//if(window.A4J.AJAX && window.A4J.AJAX.XMLHttpRequest) return;
Modified: trunk/framework/src/main/javascript/dnd/epilog.js
===================================================================
--- trunk/framework/src/main/javascript/dnd/epilog.js 2007-04-23 14:43:03 UTC (rev 112)
+++ trunk/framework/src/main/javascript/dnd/epilog.js 2007-04-23 23:19:40 UTC (rev 113)
@@ -1,4 +1,4 @@
/*
* final trail for ajax jsf library
*/
- }
\ No newline at end of file
+// }
\ No newline at end of file
Modified: trunk/framework/src/main/javascript/dnd/prolog.js
===================================================================
--- trunk/framework/src/main/javascript/dnd/prolog.js 2007-04-23 14:43:03 UTC (rev 112)
+++ trunk/framework/src/main/javascript/dnd/prolog.js 2007-04-23 23:19:40 UTC (rev 113)
@@ -2,4 +2,4 @@
* Prolog for avoid execute Prototype library twice.
*/
-if(!window.DnD){
+//if(!window.DnD){
Modified: trunk/framework/src/main/javascript/prototype/epilog.js
===================================================================
--- trunk/framework/src/main/javascript/prototype/epilog.js 2007-04-23 14:43:03 UTC (rev 112)
+++ trunk/framework/src/main/javascript/prototype/epilog.js 2007-04-23 23:19:40 UTC (rev 113)
@@ -1,4 +1,4 @@
/*
* final trail for ajax jsf library
*/
- }
\ No newline at end of file
+// }
\ No newline at end of file
Modified: trunk/framework/src/main/javascript/prototype/prolog.js
===================================================================
--- trunk/framework/src/main/javascript/prototype/prolog.js 2007-04-23 14:43:03 UTC (rev 112)
+++ trunk/framework/src/main/javascript/prototype/prolog.js 2007-04-23 23:19:40 UTC (rev 113)
@@ -2,4 +2,4 @@
* Prolog for avoid execute Prototype library twice.
*/
-if(!window.Prototype){
+//if(!window.Prototype){
17 years, 8 months
JBoss Ajax4JSF SVN: r111 - trunk/docs/userguide/en/modules.
by ajax4jsf-svn-commits@lists.jboss.org
Author: vkukharchuk
Date: 2007-04-23 09:44:14 -0400 (Mon, 23 Apr 2007)
New Revision: 111
Modified:
trunk/docs/userguide/en/modules/a4jUGtechreqs.xml
Log:
Modified: trunk/docs/userguide/en/modules/a4jUGtechreqs.xml
===================================================================
--- trunk/docs/userguide/en/modules/a4jUGtechreqs.xml 2007-04-22 22:19:44 UTC (rev 110)
+++ trunk/docs/userguide/en/modules/a4jUGtechreqs.xml 2007-04-23 13:44:14 UTC (rev 111)
@@ -96,10 +96,10 @@
Internet Explorer 5 - 7
</listitem>
<listitem>
- Firefox 1.0 - 2.0
+ Firefox 1.5 - 2.0
</listitem>
<listitem>
- Opera 8.0 - 9.0
+ Opera 8.5 - 9.0
</listitem>
<listitem>
Netscape 7.0
17 years, 8 months