Author: maksimkaszynski
Date: 2007-08-31 13:27:46 -0400 (Fri, 31 Aug 2007)
New Revision: 2674
Added:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ListenerTagGenerator.java
trunk/cdk/generator/src/main/resources/META-INF/templates/listener_tag.vm
trunk/cdk/generator/src/main/resources/META-INF/templates12/listener_tag.vm
Modified:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBean.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/JsfBean.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTagGenerator.java
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TaglibGenerator.java
trunk/cdk/generator/src/main/resources/META-INF/templates/taglib.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
trunk/ui/tree/src/main/config/component/commonTreeListeners.ent
Log:
RF-781
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-08-31
17:06:54 UTC (rev 2673)
+++
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBean.java 2007-08-31
17:27:46 UTC (rev 2674)
@@ -46,7 +46,7 @@
/**
* Component child facets, for faces-config.xml
*/
- private Set _facets = new HashSet();
+ private Set<JsfBean> _facets = new HashSet<JsfBean>();
/**
* Renderer description for this components
@@ -61,7 +61,7 @@
/**
* @return Returns the facet.
*/
- public Set getFacets() {
+ public Set<JsfBean> getFacets() {
return _facets;
}
@@ -139,7 +139,7 @@
// Attempt to check component Family
if (null == getFamily()) {
try {
- Class superClass = getLoader().loadClass(getSuperclass());
+ Class<?> superClass = getLoader().loadClass(getSuperclass());
Object componentInstance = superClass
.newInstance();
String family = (String) PropertyUtils.getProperty(componentInstance,
"family");
Modified: trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/JsfBean.java
===================================================================
--- trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/JsfBean.java 2007-08-31
17:06:54 UTC (rev 2673)
+++ trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/config/JsfBean.java 2007-08-31
17:27:46 UTC (rev 2674)
@@ -223,7 +223,7 @@
return true;
}
try {
- Class beanClass;
+ Class<?> beanClass;
try {
beanClass = getLoader().loadClass(classname);
} catch (ClassNotFoundException e) {
@@ -232,7 +232,7 @@
}
beanClass = getLoader().loadClass(getSuperclass());
}
- Class superClass = getLoader().loadClass(name);
+ Class<?> superClass = getLoader().loadClass(name);
return superClass.isAssignableFrom(beanClass);
} catch (ClassNotFoundException e) {
getLog().warn("Could't instantiate for testing class "+classname);
@@ -250,7 +250,7 @@
*/
public boolean haveMethod(String name) {
try {
- Class beanClass;
+ Class<?> beanClass;
try {
beanClass = getLoader().loadClass(getClassname());
} catch (ClassNotFoundException e) {
Modified:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTagGenerator.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTagGenerator.java 2007-08-31
17:06:54 UTC (rev 2673)
+++
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTagGenerator.java 2007-08-31
17:27:46 UTC (rev 2674)
@@ -86,7 +86,7 @@
context.put("generator",this);
Template template = getTemplate();
// Put common properties
- for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
+ for (Iterator<ComponentBean> iter = config.getComponents().iterator();
iter.hasNext();) {
ComponentBean component = (ComponentBean) iter.next();
TagBean tag = component.getTag();
if ( null != tag && null !=tag.getClassname() && tag.isGenerate()) {
@@ -100,7 +100,7 @@
context.put("tag", component.getTag());
context.put("package", component.getTag().getPackageName());
Set<String> importClasses = new HashSet<String>();
- for (Iterator it = component.getProperties().iterator(); it
+ for (Iterator<PropertyBean> it = component.getProperties().iterator(); it
.hasNext();) {
PropertyBean property = (PropertyBean) it.next();
// For non-primitive types, add import declaration.
Added:
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ListenerTagGenerator.java
===================================================================
---
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ListenerTagGenerator.java
(rev 0)
+++
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ListenerTagGenerator.java 2007-08-31
17:27:46 UTC (rev 2674)
@@ -0,0 +1,88 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - 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.List;
+
+import org.ajax4jsf.builder.config.BuilderConfig;
+import org.ajax4jsf.builder.config.ListenerBean;
+import org.ajax4jsf.builder.config.TagBean;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+
+/**
+ *
+ * @author Maksim Kaszynski
+ *
+ */
+
+public class ListenerTagGenerator extends InnerGenerator {
+
+ public ListenerTagGenerator(JSFGeneratorConfiguration config, Logger log) {
+ super(config, log);
+ }
+
+ @Override
+ protected String getDefaultTemplateName() {
+ return "listener_tag.vm";
+ }
+
+ @Override
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+ // Put common properties
+ List<ListenerBean> listeners = config.getListeners();
+ for (ListenerBean bean : listeners) {
+ TagBean tagHandler = bean.getTag();
+ if ( null != tagHandler && tagHandler.isGenerate() && null
!=tagHandler.getClassname()) {
+ context.put("tag", tagHandler);
+ context.put("listener", bean);
+
+ 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 Listener JSP Tag Java file ", e);
+ }
+ }
+ }
+ }
+
+}
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-08-31
17:06:54 UTC (rev 2673)
+++
trunk/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TaglibGenerator.java 2007-08-31
17:27:46 UTC (rev 2674)
@@ -32,6 +32,7 @@
import org.ajax4jsf.builder.config.BuilderConfig;
import org.ajax4jsf.builder.config.ComponentBean;
import org.ajax4jsf.builder.config.ConverterBean;
+import org.ajax4jsf.builder.config.ListenerBean;
import org.ajax4jsf.builder.config.ValidatorBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
@@ -103,8 +104,8 @@
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();
+ for (Iterator<ComponentBean> iter = config.getComponents().iterator();
iter.hasNext();) {
+ ComponentBean component = iter.next();
boolean includeComponent = true;
// Check include patterns
if (component.getTag() != null && (component.getTag().getTaglib() == null ||
component.getTag().getTaglib().equals(getShortname()))) {
@@ -118,8 +119,8 @@
}
}
List<ValidatorBean> validators = new ArrayList<ValidatorBean>();
- for (Iterator iter = config.getValidators().iterator(); iter.hasNext();) {
- ValidatorBean validator = (ValidatorBean) iter.next();
+ for (Iterator<ValidatorBean> iter = config.getValidators().iterator();
iter.hasNext();) {
+ ValidatorBean validator = iter.next();
boolean includeComponent = true;
// Check include patterns
if (validator.getTag() != null && (validator.getTag().getTaglib() ==
null || validator.getTag().getTaglib().equals(getShortname()))) {
@@ -133,8 +134,8 @@
}
}
List<ConverterBean> converters = new ArrayList<ConverterBean>();
- for (Iterator iter = config.getConverters().iterator(); iter.hasNext();) {
- ConverterBean converter = (ConverterBean) iter.next();
+ for (Iterator<ConverterBean> iter = config.getConverters().iterator();
iter.hasNext();) {
+ ConverterBean converter = iter.next();
boolean includeComponent = true;
// Check include patterns
if (converter.getTag() != null && (converter.getTag().getTaglib() ==
null || converter.getTag().getTaglib().equals(getShortname()))) {
@@ -147,6 +148,25 @@
}
}
}
+
+
+ List<ListenerBean> listeners = new ArrayList<ListenerBean>();
+ for (Iterator<ListenerBean> iter = config.getListeners().iterator();
iter.hasNext();) {
+ ListenerBean listener = iter.next();
+ boolean includeComponent = true;
+ // Check include patterns
+ if (listener.getTag() != null && (listener.getTag().getTaglib() ==
null || listener.getTag().getTaglib().equals(getShortname()))) {
+ includeComponent = isIncludeComponent(listener);
+ if (includeComponent) {
+ info("Listener "+listener.getName() +" included in
taglib "+getShortname());
+ listeners.add(listener);
+ } else {
+ info("Listener "+listener.getName() +" excluded from
taglib "+getShortname());
+ }
+ }
+ }
+
+
if (compmnents.size() > 0 || validators.size() > 0 || converters.size() > 0)
{
VelocityContext context = new VelocityContext();
Template template = getTemplate();
@@ -160,6 +180,9 @@
if (converters.size() > 0) {
context.put("converters", converters);
}
+ if (listeners.size() > 0) {
+ context.put("listeners", listeners);
+ }
context.put("taglib", this);
File taglibFile = getTaglib();//new File(getDestDir(), resultPath);
File javaDir = taglibFile.getParentFile();
Added: trunk/cdk/generator/src/main/resources/META-INF/templates/listener_tag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/listener_tag.vm
(rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/listener_tag.vm 2007-08-31
17:27:46 UTC (rev 2674)
@@ -0,0 +1,221 @@
+/**
+ * GENERATED FILE - DO NOT EDIT
+ *
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.1 - Ajax4jsf Component Library
+ *
+ * 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 ${tag.packageName};
+
+#foreach($import in $imports)
+import $import ;
+#end
+import ${listener.componentclass};
+
+import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.ValueBinding;
+import javax.faces.webapp.UIComponentTag;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.apache.commons.beanutils.ConvertUtils;
+
+import org.ajax4jsf.Messages;
+
+
+public class $tag.simpleClassName extends TagSupport {
+
+ private static final long serialVersionUID = -274448680242671987L;
+
+ private String type;
+ private String binding;
+
+ public int doStartTag() throws JspException {
+
+ UIComponentTag parentTag = UIComponentTag
+ .getParentUIComponentTag(pageContext);
+
+ if (parentTag == null) {
+ throw new JspException(Messages.getMessage(
+ Messages.NO_UI_COMPONENT_TAG_ANCESTOR_ERROR, this
+ .getClass().getName()));
+ }
+
+ if (type == null && binding == null) {
+ throw new JspException("Either of the following attributes is "
+ + "required: type binding");
+ }
+
+ // Process only newly created components
+ if (parentTag.getCreated()) {
+
+ FacesContext context = FacesContext.getCurrentInstance();
+ Application application = context.getApplication();
+
+ ${listener.listenerclass} listener = null;
+
+ UIComponent component = parentTag.getComponentInstance();
+
+ // First try to access listener binding
+ if (binding != null) {
+ ValueBinding valueBinding = application
+ .createValueBinding(binding);
+
+ try {
+ listener = (${listener.listenerclass}) valueBinding
+ .getValue(context);
+ } catch (EvaluationException e) {
+ throw new JspException(e);
+ }
+ }
+
+ // Then try to instantiate it by type attribute
+ if (listener == null) {
+
+ String className = null;
+
+ if (UIComponentTag.isValueReference(type)) {
+
+ try {
+ className = (String) application.createValueBinding(
+ type).getValue(context);
+ } catch (EvaluationException e) {
+ throw new JspException(e);
+ }
+
+ } else {
+ className = type;
+ }
+
+ if (className == null) {
+ throw new JspException("Type attribute resolved to null.");
+ }
+
+ try {
+ listener = (${listener.listenerclass}) Class.forName(className)
+ .newInstance();
+ } catch (Exception e) {
+ throw new JspException(Messages.getMessage(
+ Messages.INSTANTIATE_LISTENER_ERROR, className,
+ component.getId()), e);
+ }
+
+ }
+
+ #foreach( $prop in $listener.properties )
+ #if( !$prop.existintag )
+ if (_${prop.name} != null)
+ {
+ #if( ${prop.el} )
+ if (UIComponentTag.isValueReference(_${prop.name}))
+ {
+ ValueBinding vb = application.createValueBinding(_${prop.name});
+ listener.${prop.setterName}((${prop.simpleClassName})
vb.getValue(facesContext));
+ }
+ #if (!${prop.elonly})
+ else
+ {
+ listener.${prop.setterName}((${prop.simpleClassName})
ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
+ }
+ #end
+ }
+ #else
+ listener.${prop.setterName}((${prop.simpleClassName})
ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
+ #end
+ #end
+ #end
+
+ // If listener was found/created, append it to component
+ if (listener != null) {
+ (($listener.componentclass) component)
+ .${listener.methodname}(listener);
+ }
+
+
+ }
+
+ return SKIP_BODY;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getBinding() {
+ return binding;
+ }
+
+ public void setBinding(String binding) {
+ this.binding = binding;
+ }
+
+ public void release() {
+ type = null;
+ binding = null;
+ }
+
+// Fields
+#foreach( $prop in $listener.properties )
+#if( !$prop.existintag )
+ /*
+ * $prop.name
+ * ${prop.xmlEncodedDescription}
+ */
+ private String _$prop.name = null;
+
+#end
+#end
+// Setters
+#foreach( $prop in $listener.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
+
+
+
+
+}
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates/taglib.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates/taglib.vm 2007-08-31
17:06:54 UTC (rev 2673)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates/taglib.vm 2007-08-31
17:27:46 UTC (rev 2674)
@@ -130,6 +130,62 @@
#end
#end
+#foreach( $listener in ${listeners})
+ #if($listener.tag)
+ <tag>
+ #if($listener.tag.name)
+ <name>${listener.tag.name}</name>
+ #else
+ <name>${listener.name}</name>
+ #end
+ <tag-class>${listener.tag.classname}</tag-class>
+ <body-content>${listener.tag.bodyContent}</body-content>
+ #if(${listener.tag.displayname})
+ <display-name>${listener.tag.xmlEncodedDisplayname}</display-name>
+ #elseif(${listener.displayname})
+ <display-name>${listener.xmlEncodedDisplayname}</display-name>
+ #end
+ #if(${listener.tag.description})
+ <description>${listener.tag.xmlEncodedDescription}</description>
+ #elseif(${listener.xmlEncodedDescription})
+ <description>${listener.xmlEncodedDescription}</description>
+ #end
+ <attribute>
+ <name>type</name>
+ <rtexprvalue>false</rtexprvalue>
+ <description>Type</description>
+ </attribute>
+
+ <attribute>
+ <name>binding</name>
+ <rtexprvalue>false</rtexprvalue>
+ <description>Binding</description>
+ </attribute>
+
+ #foreach( $prop in ${listener.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/listener_tag.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/listener_tag.vm
(rev 0)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/listener_tag.vm 2007-08-31
17:27:46 UTC (rev 2674)
@@ -0,0 +1,221 @@
+/**
+ * GENERATED FILE - DO NOT EDIT
+ *
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.1 - Ajax4jsf Component Library
+ *
+ * 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 ${tag.packageName};
+
+#foreach($import in $imports)
+import $import ;
+#end
+import ${listener.componentclass};
+
+import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.ValueBinding;
+import javax.faces.webapp.UIComponentTag;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.apache.commons.beanutils.ConvertUtils;
+
+import org.ajax4jsf.Messages;
+
+
+public class $tag.simpleClassName extends TagSupport {
+
+ private static final long serialVersionUID = -274448680242671987L;
+
+ private String type;
+ private String binding;
+
+ public int doStartTag() throws JspException {
+
+ UIComponentTag parentTag = UIComponentTag
+ .getParentUIComponentTag(pageContext);
+
+ if (parentTag == null) {
+ throw new JspException(Messages.getMessage(
+ Messages.NO_UI_COMPONENT_TAG_ANCESTOR_ERROR, this
+ .getClass().getName()));
+ }
+
+ if (type == null && binding == null) {
+ throw new JspException("Either of the following attributes is "
+ + "required: type binding");
+ }
+
+ // Process only newly created components
+ if (parentTag.getCreated()) {
+
+ FacesContext context = FacesContext.getCurrentInstance();
+ Application application = context.getApplication();
+
+ ${listener.listenerclass} listener = null;
+
+ UIComponent component = parentTag.getComponentInstance();
+
+ // First try to access listener binding
+ if (binding != null) {
+ ValueBinding valueBinding = application
+ .createValueBinding(binding);
+
+ try {
+ listener = (${listener.listenerclass}) valueBinding
+ .getValue(context);
+ } catch (EvaluationException e) {
+ throw new JspException(e);
+ }
+ }
+
+ // Then try to instantiate it by type attribute
+ if (listener == null) {
+
+ String className = null;
+
+ if (UIComponentTag.isValueReference(type)) {
+
+ try {
+ className = (String) application.createValueBinding(
+ type).getValue(context);
+ } catch (EvaluationException e) {
+ throw new JspException(e);
+ }
+
+ } else {
+ className = type;
+ }
+
+ if (className == null) {
+ throw new JspException("Type attribute resolved to null.");
+ }
+
+ try {
+ listener = (${listener.listenerclass}) Class.forName(className)
+ .newInstance();
+ } catch (Exception e) {
+ throw new JspException(Messages.getMessage(
+ Messages.INSTANTIATE_LISTENER_ERROR, className,
+ component.getId()), e);
+ }
+
+ }
+
+ #foreach( $prop in $listener.properties )
+ #if( !$prop.existintag )
+ if (_${prop.name} != null)
+ {
+ #if( ${prop.el} )
+ if (UIComponentTag.isValueReference(_${prop.name}))
+ {
+ ValueBinding vb = application.createValueBinding(_${prop.name});
+ listener.${prop.setterName}((${prop.simpleClassName})
vb.getValue(facesContext));
+ }
+ #if (!${prop.elonly})
+ else
+ {
+ listener.${prop.setterName}((${prop.simpleClassName})
ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
+ }
+ #end
+ }
+ #else
+ listener.${prop.setterName}((${prop.simpleClassName})
ConvertUtils.convert(_${prop.name}, ${prop.simpleClassName}.class));
+ #end
+ #end
+ #end
+
+ // If listener was found/created, append it to component
+ if (listener != null) {
+ (($listener.componentclass) component)
+ .${listener.methodname}(listener);
+ }
+
+
+ }
+
+ return SKIP_BODY;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getBinding() {
+ return binding;
+ }
+
+ public void setBinding(String binding) {
+ this.binding = binding;
+ }
+
+ public void release() {
+ type = null;
+ binding = null;
+ }
+
+// Fields
+#foreach( $prop in $listener.properties )
+#if( !$prop.existintag )
+ /*
+ * $prop.name
+ * ${prop.xmlEncodedDescription}
+ */
+ private String _$prop.name = null;
+
+#end
+#end
+// Setters
+#foreach( $prop in $listener.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
+
+
+
+
+}
Modified: trunk/cdk/generator/src/main/resources/META-INF/templates12/taglib.vm
===================================================================
--- trunk/cdk/generator/src/main/resources/META-INF/templates12/taglib.vm 2007-08-31
17:06:54 UTC (rev 2673)
+++ trunk/cdk/generator/src/main/resources/META-INF/templates12/taglib.vm 2007-08-31
17:27:46 UTC (rev 2674)
@@ -130,6 +130,44 @@
#end
#end
+#foreach( $listener in ${listeners})
+ #if($listener.tag)
+ <tag>
+ <name>${listener.tag.name}</name>
+ <tag-class>${listener.tag.classname}</tag-class>
+ <body-content>${listener.tag.bodyContent}</body-content>
+ #if(${listener.tag.displayname})
+ <display-name>${listener.tag.xmlEncodedDisplayname}</display-name>
+ #elseif(${listener.displayname})
+ <display-name>${listener.xmlEncodedDisplayname}</display-name>
+ #end
+ #if(${listener.tag.description})
+ <description>${listener.tag.xmlEncodedDescription}</description>
+ #elseif(${listener.xmlEncodedDescription})
+ <description>${listener.xmlEncodedDescription}</description>
+ #end
+ #foreach( $prop in ${listener.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
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-08-31
17:06:54 UTC (rev 2673)
+++
trunk/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateMojo.java 2007-08-31
17:27:46 UTC (rev 2674)
@@ -34,6 +34,7 @@
import org.ajax4jsf.builder.generator.GeneratorException;
import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
import org.ajax4jsf.builder.generator.ListenerGenerator;
+import org.ajax4jsf.builder.generator.ListenerTagGenerator;
import org.ajax4jsf.builder.generator.RenderKitBean;
import org.ajax4jsf.builder.generator.RendererGenerator;
import org.ajax4jsf.builder.generator.ResourcesConfigGenerator;
@@ -124,7 +125,12 @@
ConverterTagGenerator converterTagGenerator = new ConverterTagGenerator(this,
mavenLogger);
converterTagGenerator.createFiles(config);
- // GenerateMojo tag test
+
+ ListenerTagGenerator listenerTagGenerator = new ListenerTagGenerator(this,
mavenLogger);
+ listenerTagGenerator.createFiles(config);
+
+
+ // GenerateMojo tag test
/*
TagTestGenerator tagTestGenerator = new TagTestGenerator(this, mavenLogger);
tagTestGenerator.setDestDir(outputTestsDirectory);
Modified: trunk/ui/tree/src/main/config/component/commonTreeListeners.ent
===================================================================
--- trunk/ui/tree/src/main/config/component/commonTreeListeners.ent 2007-08-31 17:06:54
UTC (rev 2673)
+++ trunk/ui/tree/src/main/config/component/commonTreeListeners.ent 2007-08-31 17:27:46
UTC (rev 2674)
@@ -51,6 +51,11 @@
org.richfaces.taglib.ChangeExpandListenerTagHandler
</classname>
</taghandler>
+ <tag generate="true">
+ <classname>
+ org.richfaces.taglib.ChangeExpandListenerTag
+ </classname>
+ </tag>
</listener>
<listener>
<name>nodeSelectListener</name>
@@ -68,4 +73,9 @@
org.richfaces.taglib.NodeSelectListenerTagHandler
</classname>
</taghandler>
+ <tag generate="true">
+ <classname>
+ org.richfaces.taglib.NodeSelectListenerTag
+ </classname>
+ </tag>
</listener>