Author: baranda
Date: Mon Nov 27 11:44:03 2006
New Revision: 479737

URL: http://svn.apache.org/viewvc?view=rev&rev=479737
Log:
Applied ADFFACES-306 patch (enhancements and fixes for the maven-myfaces-plugin 
(Part 2)) by Andreas Berger

Modified:
    
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java
    
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
    
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java
    
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java
    
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/MyFacesComponentGenerator.java
    
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/TrinidadComponentGenerator.java
    
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
    
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Util.java

Modified: 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java?view=diff&rev=479737&r1=479736&r2=479737
==============================================================================
--- 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java
 (original)
+++ 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/AbstractFacesMojo.java
 Mon Nov 27 11:44:03 2006
@@ -611,22 +611,23 @@
 "//          or you will lose your changes.\n\n";
 
 
-  static private final int _CURRENT_YEAR = new 
GregorianCalendar().get(Calendar.YEAR);
-
   static final private String _DEFAULT_LICENSE_HEADER =
-        "/*\n" +
-        "* Copyright "+_CURRENT_YEAR+" The Apache Software Foundation.\n" +
-        "*\n" +
-        "* Licensed under the Apache License, Version 2.0 (the 
\"License\");\n" +
-        "* you may not use this file except in compliance with the License.\n" 
+
-        "* You may obtain a copy of the License at\n" +
-        "*\n" +
-        "*     http://www.apache.org/licenses/LICENSE-2.0\n"; +
-        "*\n" +
-        "* Unless required by applicable law or agreed to in writing, 
software\n" +
-        "* distributed under the License is distributed on an \"AS IS\" 
BASIS,\n" +
-        "* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.\n" +
-        "* See the License for the specific language governing permissions 
and\n" +
-        "* limitations under the License.\n" +
-        "*/\n";
+                  "/*\n" +
+                  " * Licensed to the Apache Software Foundation (ASF) under 
one\n" +
+                  " * or more contributor license agreements.  See the NOTICE 
file\n" +
+                  " * distributed with this work for additional information\n" 
+
+                  " * regarding copyright ownership.  The ASF licenses this 
file\n" +
+                  " * to you under the Apache License, Version 2.0 (the\n" +
+                  " * \"License\"); you may not use this file except in 
compliance\n" +
+                  " * with the License.  You may obtain a copy of the License 
at\n" +
+                  " *\n" +
+                  " *   http://www.apache.org/licenses/LICENSE-2.0\n"; +
+                  " *\n" +
+                  " * Unless required by applicable law or agreed to in 
writing,\n" +
+                  " * software distributed under the License is distributed on 
an\n" +
+                  " * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 
ANY\n" +
+                  " * KIND, either express or implied.  See the License for 
the\n" +
+                  " * specific language governing permissions and 
limitations\n" +
+                  " * under the License.\n" +
+                  "*/";
 }

Modified: 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java?view=diff&rev=479737&r1=479736&r2=479737
==============================================================================
--- 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
 (original)
+++ 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateComponentsMojo.java
 Mon Nov 27 11:44:03 2006
@@ -118,12 +118,11 @@
 
     if (component.isTrinidadComponent())
     {
-      generator = new TrinidadComponentGenerator(getLog());
-    }
-    else
-    {
-      generator = new MyFacesComponentGenerator(getLog());
+      generator = new TrinidadComponentGenerator(getLog(), _is12());
     }
+    else {
+               generator = new MyFacesComponentGenerator(getLog(),_is12() );
+       }
 
     try
     {
@@ -270,6 +269,12 @@
     }
   }
 
+       private boolean _is12()
+       {
+               return "1.2".equals(jsfVersion) || "12".equals(jsfVersion);
+       }
+
+
   /**
    * @parameter expression="${project}"
    * @readonly
@@ -315,4 +320,9 @@
    * @parameter
    */
   private boolean suppressListenerMethods;
+
+  /**
+   * @parameter
+   */
+  private String jsfVersion;
 }

Modified: 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java?view=diff&rev=479737&r1=479736&r2=479737
==============================================================================
--- 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java
 (original)
+++ 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java
 Mon Nov 27 11:44:03 2006
@@ -70,7 +70,19 @@
     public static boolean isActionListener(PropertyBean property, boolean is12)
     {
                return (property.getJspPropertyName().equals("actionListener") 
&&
-                               (property.isMethodExpression()) || (is12 && 
property.isMethodBinding()));
+                               ((property.isMethodExpression()) || (is12 && 
property.isMethodBinding())));
+    }
+
+    public static boolean isValueChangeListener(PropertyBean property, boolean 
is12)
+    {
+               return 
(property.getJspPropertyName().equals("valueChangeListener") &&
+                               ((property.isMethodExpression()) || (is12 && 
property.isMethodBinding())));
+    }
+
+    public static boolean isValidator(PropertyBean property, boolean is12)
+    {
+               return (property.getJspPropertyName().equals("validator")) &&
+                               ((property.isMethodExpression()) || (is12 && 
property.isMethodBinding()));
     }
 
     static public void writeImports(

Modified: 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java?view=diff&rev=479737&r1=479736&r2=479737
==============================================================================
--- 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java
 (original)
+++ 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/AbstractComponentGenerator.java
 Mon Nov 27 11:44:03 2006
@@ -46,11 +46,13 @@
 {
 
     private Log _log;
+       boolean _is12;
 
-    public AbstractComponentGenerator(Log log)
+       public AbstractComponentGenerator(Log log, boolean is12)
     {
         _log = log;
-    }
+               _is12 = is12;
+       }
 
     protected Log getLog()
     {
@@ -544,17 +546,25 @@
         {
             PropertyBean property = (PropertyBean) properties.next();
             if (property.isList())
-                writePropertyListMethods(out, property);
+                writePropertyListMethods(out, property, ignoreList);
             else
             {
                                writePropertyDeclaration(out, property);
                 writePropertyGet(out, property, ignoreList);
                 writePropertySet(out, property, ignoreList);
-            }
-        }
+                               if (GeneratorHelper.isValidator(property, 
_is12)){
+                                       writePropertyListMethods(out, property, 
ignoreList);
+                               }
+                       }
+               }
        }
 
        abstract protected void writePropertyListMethods(
+                       PrettyWriter out,
+                       PropertyBean property,
+                       Collection inoreList) throws IOException;
+
+       abstract protected void writePropertyListMethods(
             PrettyWriter out,
             PropertyBean property) throws IOException;
 
@@ -611,7 +621,11 @@
         }
         out.println(" * ");
         out.println(" * @param " + propName + "  the new " + propName + " 
value");
-        out.println(" */");
+               if (property.isMethodBinding() && _is12)
+               {
+                       out.println(" * @deprecated");
+               }
+               out.println(" */");
 
         if (isAccessorMethodFinal())
         {
@@ -667,7 +681,11 @@
 
         out.println(" *");
         out.println(" * @return  the new " + propName + " value");
-        out.println(" */");
+               if (property.isMethodBinding() && _is12)
+               {
+                       out.println(" * @deprecated");
+               }
+               out.println(" */");
 
         if (isUnchecked)
         {
@@ -804,7 +822,7 @@
                 writeListenersGet(out, event);
             }
         }
-    }
+       }
 
     public void writeListenerAdd(
             PrettyWriter out,

Modified: 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/MyFacesComponentGenerator.java
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/MyFacesComponentGenerator.java?view=diff&rev=479737&r1=479736&r2=479737
==============================================================================
--- 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/MyFacesComponentGenerator.java
 (original)
+++ 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/MyFacesComponentGenerator.java
 Mon Nov 27 11:44:03 2006
@@ -20,10 +20,13 @@
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.ComponentBean;
 import org.apache.myfaces.trinidadbuild.plugin.faces.parse.PropertyBean;
 import org.apache.myfaces.trinidadbuild.plugin.faces.util.Util;
+import org.apache.myfaces.trinidadbuild.plugin.faces.generator.GeneratorHelper;
 
 import java.io.IOException;
 import java.util.Iterator;
 import java.util.Set;
+import java.util.Collection;
+import java.util.ArrayList;
 
 /**
  * Component generator for MyFaces
@@ -33,17 +36,27 @@
  */
 public class MyFacesComponentGenerator extends AbstractComponentGenerator
 {
-    public MyFacesComponentGenerator(Log log)
+
+       public MyFacesComponentGenerator(Log log, boolean is12)
     {
-        super(log);
-    }
+        super(log, is12);              
+       }
 
 
     protected void addSpecificImports(Set imports, ComponentBean component)
     {
         imports.add("javax.faces.context.FacesContext");
         imports.add("javax.el.ValueExpression");
-    }
+               for (Iterator lIterator = component.properties(); 
lIterator.hasNext();) {
+                       PropertyBean lPropertyBean = (PropertyBean) 
lIterator.next();
+                       if (GeneratorHelper.isValidator(lPropertyBean, _is12)){
+                               imports.add("javax.faces.validator.Validator");
+                               imports.add("java.util.ArrayList");
+                               imports.add("java.util.List");
+                               break;
+                       }
+               }
+       }
 
     public void writePropertyDeclaration(PrettyWriter out,
                                          PropertyBean property) throws 
IOException
@@ -52,12 +65,15 @@
         String fieldPropName = property.getFieldPropertyName();
         String propertyFullClass = property.getPropertyClass();
         String propertyClass = Util.getClassFromFullClass(propertyFullClass);
+        String propertyGenerics = Util.getGenericsFromProperty(property);
+        String def = Util.getDefaultValue(property);
 
         out.println();
         out.println("// Property: " + propName);
-        out.println("private " + propertyClass + " " + fieldPropName + ";");
+        out.println("private " + propertyClass + propertyGenerics +  " " +
+                fieldPropName + (def==null?";":" = "+def+";"));
 
-        if (Util.isPrimitiveClass(propertyFullClass))
+        if (Util.isPrimitiveClass(propertyFullClass) && 
!property.isTagAttributeExcluded())
         {
             out.println("private boolean " + fieldPropName + "Set;");
         }
@@ -82,20 +98,120 @@
         // nothing
     }
 
-    protected void writeConstructorContent(PrettyWriter out, ComponentBean 
component, int modifiers, String rendererType) throws IOException
+       protected void writeConstructorContent(PrettyWriter out, ComponentBean 
component, int modifiers, String rendererType) throws IOException
     {
         out.println("setRendererType("+rendererType+");");
     }
 
-    protected void writePropertySetterMethodBody(PrettyWriter out,
+       protected void writePropertyListMethods(PrettyWriter out, PropertyBean 
property, Collection ignoreList)
+       {
+               String propName = property.getPropertyName();
+        String generic;
+        String type;
+        boolean  isValidator = GeneratorHelper.isValidator(property, _is12);
+        if (isValidator){
+            generic = "<Validator>";
+            type = "Validator";
+        } else if (property.getAttributeClassParameters().length == 1){
+            generic = Util.getGenericsFromProperty(property);
+            type = 
Util.getClassFromFullClass(property.getAttributeClassParameters()[0]);
+        } else {
+            throw new IllegalArgumentException("only one Generic Parameter is 
allowed for Lists");
+        }
+
+        String singularName = getSingular(propName);
+        String propVar = Util.getVariableFromName(singularName);
+        String description = property.getDescription();
+        String addMethod = Util.getPrefixedPropertyName("add", singularName);
+        String removeMethod = Util.getPrefixedPropertyName("remove", 
singularName);
+        String getMethod = Util.getPrefixedPropertyName("get", 
singularName+"s");
+               String fieldPropName = 
property.getFieldPropertyName()+(isValidator?"List":"");
+
+               out.println();
+        out.println("// Property: " + propName);
+        out.println("private List"+ generic + " " + fieldPropName + ";");
+               if (ignoreList == null || !ignoreList.contains(addMethod)){
+                       out.println();
+                       out.println("/**");
+                       if (description != null)
+                       {
+                               out.println(" * Adds a " + 
convertMultilineComment(description));
+                       }
+                       out.println(" */");
+                       out.println("public void " + addMethod + "( "+type + " 
" +
+                                       propVar + ")");
+                       out.println("{");
+                       out.indent();
+                       out.println("if ("+propVar+" == null) throw new 
NullPointerException(\""+propVar+"\");");
+                       out.println("if (" + fieldPropName + " == null)");
+                       out.println("  "+fieldPropName + " = new 
ArrayList"+generic +"();");
+                       out.println();
+                       out.println(fieldPropName+".add("+ propVar + ");");
+                       out.unindent();
+                       out.println("}");
+               }
+
+               if (ignoreList == null || !ignoreList.contains(removeMethod)){
+                       out.println();
+                       out.println("/**");
+                       if (description != null)
+                       {
+                               out.println(" * Removes a " + 
convertMultilineComment(description));
+                       }
+                       out.println(" */");
+                       out.println("public void " + removeMethod + "( "+type + 
" " + propVar + ")");
+                       out.println("{");
+                       out.indent();
+                       out.println("if (" + propVar + " == null || 
"+fieldPropName+" == null)");
+                       out.println("  return;");
+                       out.println();
+                       out.println(fieldPropName+ ".remove(" + propVar + ");");
+                       out.unindent();
+                       out.println("}");
+               }
+
+               if (ignoreList == null || !ignoreList.contains(getMethod)){
+            if (isValidator){
+                out.println("private static final "+type + "[] 
EMPTY_"+type.toUpperCase()+"_ARRAY = new "+type + "[0];");
+            }
+                       out.println();
+                       out.println("/**");
+                       if (description != null)
+                       {
+                               out.println(" * Gets all " + 
convertMultilineComment(description));
+                       }
+                       out.println(" */");
+                       if (isValidator){
+                out.println("public "+type + "[] " + getMethod + "()");
+            } else {
+                out.println("public List"+ generic + " "  + getMethod + "()");
+            }
+                       out.println("{");
+                       out.indent();
+            if (isValidator){
+                out.println("return "+fieldPropName+"== null? 
EMPTY_"+type.toUpperCase()+"_ARRAY : "+fieldPropName+".toArray(new 
"+type+"["+fieldPropName+".size()]);");
+            } else {
+                out.println("if ("+fieldPropName+" == null)");
+                out.indent();
+                out.println(fieldPropName+" = new ArrayList<"+type+">();");
+                out.unindent();
+                out.println("return "+fieldPropName+";");
+            }
+                       out.unindent();
+                       out.println("}");
+               }
+       }
+
+       protected void writePropertySetterMethodBody(PrettyWriter out,
                                               PropertyBean property,
                                               String propertyClass) throws 
IOException
     {
         String varName = property.getFieldPropertyName();
+        String propVar = Util.getVariableFromName(property.getPropertyName());
 
-        out.println("this."+varName+" = "+property.getPropertyName()+";");
+        out.println("this."+varName+" = "+ propVar +";");
 
-        if (Util.isPrimitiveClass(propertyClass))
+        if (Util.isPrimitiveClass(propertyClass) && 
!property.isTagAttributeExcluded())
         {
             out.println("this."+_primitiveSetVarName(varName)+" = true;");
         }
@@ -105,38 +221,48 @@
                                               PropertyBean property) throws 
IOException
     {
         String varName = property.getFieldPropertyName();
-        String propName = property.getPropertyName();
+        String propVar = Util.getVariableFromName(property.getPropertyName());
         String propFullClass = property.getPropertyClass();
         String propClass = Util.getClassFromFullClass(propFullClass);
-
-        if (Util.isPrimitiveClass(propFullClass))
-        {
-            out.println("if ("+ _primitiveSetVarName(varName)+")");
+        if (property.isTagAttributeExcluded()){
+            out.println("return "+property.getFieldPropertyName()+";");
         }
         else
         {
-            out.println("if ("+varName+" != null)");
-        }
-        out.println("{");
-        out.indent();
-        out.println("return "+property.getFieldPropertyName()+";");
-        out.unindent();
-        out.println("}");
-        out.println("ValueExpression expression = 
getValueExpression(\""+propName+"\");");
-        out.println("if (expression != null)");
-        out.println("{");
-        out.indent();
-        out.println("return 
"+_castIfNecessary(propClass)+"expression.getValue(getFacesContext().getELContext());");
-        out.unindent();
-        out.println("}");
+            if (Util.isPrimitiveClass(propFullClass))
+            {
+                out.println("if ("+ _primitiveSetVarName(varName)+")");
+            }
+            else
+            {
+                out.println("if ("+varName+" != null)");
+            }
+            out.println("{");
+            out.indent();
+            out.println("return "+property.getFieldPropertyName()+";");
+            out.unindent();
+            out.println("}");
+            out.println("ValueExpression expression = 
getValueExpression(\""+propVar+"\");");
+            out.println("if (expression != null)");
+            out.println("{");
+            out.indent();
+            out.println("return 
"+_castIfNecessary(propClass)+"expression.getValue(getFacesContext().getELContext());");
+            out.unindent();
+            out.println("}");
 
-        if (Util.isPrimitiveClass(propFullClass))
-        {
-            out.println("return 
"+Util.primitiveDefaultValue(propFullClass)+";");
-        }
-        else
-        {
-            out.println("return null;");
+            String ret = Util.getDefaultValue(property);
+            if (null != ret)
+            {
+                out.println("return "+ ret +";");
+            }
+            else if (Util.isPrimitiveClass(propFullClass))
+            {
+                out.println("return 
"+Util.primitiveDefaultValue(propFullClass)+";");
+            }
+            else
+            {
+                out.println("return null;");
+            }
         }
     }
 
@@ -180,7 +306,12 @@
             if (property.isStateHolder())
             {
                 out.println(arrayName+"["+propIndex+"] = 
saveAttachedState(facesContext, "+varName+");");
-            }
+                               if (GeneratorHelper.isValidator(property, 
_is12)){
+                                       out.println(arrayName+"["+ 
++propIndex+"] = saveAttachedState(facesContext, "+varName+"List);");
+                               } else if( property.isList()){
+                    out.println(arrayName+"["+ ++propIndex+"] = 
saveAttachedState(facesContext, "+varName+");");
+                }
+                       }
             else
             {
                 out.println(arrayName+"["+propIndex+"] = "+varName+";");
@@ -188,7 +319,7 @@
 
             propIndex++;
 
-            if (Util.isPrimitiveClass(property.getPropertyClass()))
+            if (Util.isPrimitiveClass(property.getPropertyClass()) && 
!property.isTagAttributeExcluded())
             {
                 out.println(arrayName+"["+propIndex+"] = 
"+_primitiveSetVarName(varName)+";");
                 propIndex++;
@@ -229,7 +360,15 @@
             {
                 out.println(varName + " = 
"+_castIfNecessary(propClass)+"restoreAttachedState(facesContext, "
                     + arrayName + "[" + propIndex + "]);");
-            }
+                               if (GeneratorHelper.isValidator(property, 
_is12)){
+                                       out.println(varName + "List = 
(List<Validator>) restoreAttachedState(facesContext, "
+                    + arrayName + "[" + ++propIndex + "]);");
+                               } else if( property.isList()){
+                    out.println(varName + " = (List) 
restoreAttachedState(facesContext, "
+                    + arrayName + "[" + ++propIndex + "]);");
+                }
+
+                       }
             else
             {
                 out.println(varName + " = " + _castIfNecessary(propClass)
@@ -238,7 +377,7 @@
 
             propIndex++;
 
-            if (Util.isPrimitiveClass(property.getPropertyClass()))
+            if (Util.isPrimitiveClass(property.getPropertyClass()) && 
!property.isTagAttributeExcluded())
             {
                 out.println(_primitiveSetVarName(varName) + " = (Boolean)"
                     + arrayName + "[" + propIndex + "];");

Modified: 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/TrinidadComponentGenerator.java
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/TrinidadComponentGenerator.java?view=diff&rev=479737&r1=479736&r2=479737
==============================================================================
--- 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/TrinidadComponentGenerator.java
 (original)
+++ 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/component/TrinidadComponentGenerator.java
 Mon Nov 27 11:44:03 2006
@@ -29,12 +29,13 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+import java.util.Collection;
 
 public class TrinidadComponentGenerator extends AbstractComponentGenerator
 {
-    public TrinidadComponentGenerator(Log log)
+    public TrinidadComponentGenerator(Log log, boolean is12)
     {
-        super(log);
+        super(log, is12);
     }
 
     protected void addSpecificImports(Set imports, ComponentBean component)
@@ -70,7 +71,11 @@
         out.println("super("+rendererType+");");
     }
 
-    public void writePropertyConstants(
+       protected void writePropertyListMethods(PrettyWriter out, PropertyBean 
property, Collection gnoreList) {
+               // nothing
+       }
+
+       public void writePropertyConstants(
             PrettyWriter out,
             String superclassName,
             ComponentBean component) throws IOException
@@ -311,8 +316,7 @@
         out.println("}");
     }
 
-
-    public void writeOther(PrettyWriter out, ComponentBean component) throws 
IOException
+       public void writeOther(PrettyWriter out, ComponentBean component) 
throws IOException
     {
         _writeGetBeanType(out);
 

Modified: 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java?view=diff&rev=479737&r1=479736&r2=479737
==============================================================================
--- 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
 (original)
+++ 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
 Mon Nov 27 11:44:03 2006
@@ -28,6 +28,7 @@
 import java.util.Set;
 import java.util.Collection;
 import java.util.HashSet;
+import java.awt.event.ActionListener;
 
 /**
  * Component tag generator for myfaces
@@ -80,6 +81,14 @@
                                        {
                                                
imports.add("javax.faces.event.MethodExpressionActionListener");
                                        }
+                    if (GeneratorHelper.isValueChangeListener(property, _is12))
+                                       {
+                                               
imports.add("javax.faces.event.MethodExpressionValueChangeListener");
+                                       }
+                    if (GeneratorHelper.isValidator(property, _is12))
+                                       {
+                                               
imports.add("javax.faces.validator.MethodExpressionValidator");
+                                       }
                                }
                 else
                 {
@@ -94,6 +103,14 @@
             {
                 
imports.add("javax.faces.event.MethodExpressionActionListener");
             }
+            else if (GeneratorHelper.isValueChangeListener(property, _is12))
+            {
+                
imports.add("javax.faces.event.MethodExpressionValueChangeListener");
+            }
+            else if (GeneratorHelper.isValidator(property, _is12))
+            {
+                imports.add("javax.faces.validator.MethodExpressionValidator");
+            }
         }
     }
 
@@ -220,7 +237,7 @@
       {
         _writeSetConverter(out, componentClass, propName);
       }
-      else 
+      else
       {
         _writeSetProperty(out, propName, propVar);
       }
@@ -286,7 +303,17 @@
                        if (GeneratorHelper.isActionListener(property, _is12))
                        {
                                out.println("comp.addActionListener(new 
MethodExpressionActionListener(" + propVar + "));");
-                       } else {
+                       }
+                       else if 
(GeneratorHelper.isValueChangeListener(property, _is12))
+                       {
+                               out.println("comp.addValueChangeListener(new 
MethodExpressionValueChangeListener(" + propVar + "));");
+                       }
+            else if (GeneratorHelper.isValidator(property, _is12))
+                       {
+                               out.println("comp.addValidator(new 
MethodExpressionValidator(" + propVar + "));");
+                       }
+                       else
+                       {
                                out.println("bean.setProperty(" + 
componentClass + "." + propKey + ", " +
                                                "new 
MethodExpressionMethodBinding(" + propVar + "));");
                        }
@@ -454,7 +481,7 @@
             out.println("if (!" + propVar + ".isLiteralText())");
             out.println("{");
             out.indent();
-            out.println("bean.setValueExpression(" + componentClass + "." + 
propKey + ", " + propVar + ");");
+            out.println("comp.setValueExpression(\""+propName+"\", 
"+propVar+");");
             out.unindent();
             out.println("}");
             out.println("else");
@@ -469,7 +496,7 @@
             out.indent();
             out.println("createConverter(o.toString());");
             out.unindent();
-            out.println("bean.setProperty(" + componentClass + "." + propKey + 
", converter);");
+            out.println("comp.setConverter(converter);");
 
             out.unindent();
             out.println("}");

Modified: 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Util.java
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Util.java?view=diff&rev=479737&r1=479736&r2=479737
==============================================================================
--- 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Util.java
 (original)
+++ 
incubator/adffaces/branches/myfaces-1_2-maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/util/Util.java
 Mon Nov 27 11:44:03 2006
@@ -39,6 +39,17 @@
     return (className != null && className.indexOf('.') != -1);
   }
 
+  public static String getGenericsFromProperty(PropertyBean property){
+      String gen = "";
+      for (int i = 0; i < property.getAttributeClassParameters().length; i++) {
+          if (i>0){
+              gen += ",";
+          }
+          gen += 
getClassFromFullClass(property.getAttributeClassParameters()[i]);          
+      }
+      return (gen.length() > 0?"<"+gen+">":gen);
+  }
+
   static public String getClassFromFullClass(
     String fullClass)
   {
@@ -46,7 +57,6 @@
       return null;
 
     int lastSep = fullClass.lastIndexOf('.');
-
     // Note: this code also works for the empty package
     return (fullClass.substring(lastSep + 1));
   }
@@ -296,6 +306,24 @@
       return value;
     }
   }
+
+    static public String getDefaultValue(PropertyBean property){
+        String propertyFullClass = property.getPropertyClass();
+        String def = property.getDefaultValue();
+        if (def == null || def.length() == 0){
+            return null;
+        }
+        if (isPrimitiveClass(propertyFullClass)){
+            return def;
+        } else if ("java.lang.String".equals(propertyFullClass)){
+            if (def.startsWith("\"") && def.endsWith("\"")){
+                return def;
+            } else {
+                return "\""+def+"\"";
+            }
+        }
+        return null;
+    }
 
     static private void _buildPropertyClass(StringBuffer buffer, String type)
   {


Reply via email to