You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2009/03/20 07:33:59 UTC

svn commit: r756342 - in /myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator: GeneratorHelper.java taglib/TrinidadComponentTagGenerator.java

Author: matzew
Date: Fri Mar 20 06:33:59 2009
New Revision: 756342

URL: http://svn.apache.org/viewvc?rev=756342&view=rev
Log:
TRINIDAD-1414 - Implement support for specifying List<String> attribute type as String

Applying the plugin specific patch;
Thanks to Yee-wah Lee

Modified:
    myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java
    myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java

Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java?rev=756342&r1=756341&r2=756342&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/GeneratorHelper.java Fri Mar 20 06:33:59 2009
@@ -72,6 +72,17 @@
         "java.awt.Color".equals(propClassParams[0]));
   }
 
+  // Allows List of known types, kept in sync
+  // with UIXComponentELTag's set*List methods.
+  public static boolean isKnownTypeList (
+      String propClass,
+      String[] propClassParams)
+  {
+    return ("java.util.List".equals(propClass) &&
+        propClassParams.length == 1 &&
+        "java.lang.String".equals(propClassParams[0]));
+  }
+
   public static boolean isColor(
       String propClass)
   {

Modified: myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java?rev=756342&r1=756341&r2=756342&view=diff
==============================================================================
--- myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java (original)
+++ myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java Fri Mar 20 06:33:59 2009
@@ -291,6 +291,12 @@
     {
       _writeSetColor(out, componentClass, propName, false);
     }
+    else if (GeneratorHelper.isKnownTypeList(propClass,  
+                                    property.getPropertyClassParameters()))
+    {
+      _writeSetKnownTypeList (out, componentClass, propName, 
+                     property.getPropertyClassParameters()[0]);
+    }
     else if (GeneratorHelper.isConverter(propClass))
     {
       _writeSetConverter(out, componentClass, propName);
@@ -849,6 +855,63 @@
     out.println("}");
   }
 
+  private void _writeSetKnownTypeList(
+      PrettyWriter out,
+      String  componentClass,
+      String  propName,
+      String  propFullClass) throws IOException
+  {
+    String propKey = Util.getConstantNameFromProperty(propName, "_KEY");
+    String propVar = "_" + propName;
+    
+    String propClass = Util.getClassFromFullClass(propFullClass);
+    String boxedClass = Util.getBoxedClass(propClass);
+
+    System.out.println ("_writeSetList: propFullClass = " + propFullClass +
+                        " propClass= " + propClass + 
+                        " boxedClass=" + boxedClass);
+    if (_is12)
+    {
+      out.println("set" + boxedClass + "ListProperty" + 
+                  "(bean, " + componentClass + "." + propKey + 
+                  ", " + propVar + ");");
+    }
+    else
+    {
+      out.println("if (" + propVar + " != null)");
+      out.println("{");
+      out.indent();
+      out.println("if (isValueReference(" + propVar + "))");
+      out.println("{");
+      out.indent();
+      out.println("ValueBinding vb = createValueBinding(" + propVar + ");");
+      out.println("bean.setValueBinding(" + componentClass + "." + propKey + ", vb);");
+      out.unindent();
+      out.println("}");
+      out.println("else");
+      out.println("{");
+      out.indent();
+      out.println("try");
+      out.println("{");
+      out.indent();
+      out.println("bean.setProperty(" + componentClass + "." + propKey + ",");
+      out.println("                 TagUtils.getStringList(" + propVar + "));");
+      out.unindent();
+      out.println("}");
+      out.println("catch (ParseException pe)");
+      out.println("{");
+      out.indent();
+      out.println("setValidationError(");
+      out.println("  pe.getMessage() + \": \" + \"Position \" + pe.getErrorOffset());");
+      out.unindent();
+      out.println("}");
+      out.unindent();
+      out.println("}");
+      out.unindent();
+      out.println("}");
+    }
+  }
+
 
   private void _writeSetConverter(
       PrettyWriter out,