myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwald...@apache.org
Subject svn commit: r781894 - in /myfaces/trinidad-maven/trunk/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator: GeneratorHelper.java taglib/TrinidadComponentTagGenerator.java
Date Fri, 05 Jun 2009 02:28:54 GMT
Author: jwaldman
Date: Fri Jun  5 02:28:54 2009
New Revision: 781894

URL: http://svn.apache.org/viewvc?rev=781894&view=rev
Log:
TRINIDAD-1494 Support java.util.Set as property type
trunk of plugins.
For Jing Wu

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=781894&r1=781893&r2=781894&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 Jun  5 02:28:54 2009
@@ -83,6 +83,17 @@
         "java.lang.String".equals(propClassParams[0]));
   }
 
+  // Allows Set of known types, kept in sync
+  // with UIXComponentELTag's set*Set methods.
+  public static boolean isKnownTypeSet (
+      String propClass,
+      String[] propClassParams)
+  {
+    return ("java.util.Set".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=781894&r1=781893&r2=781894&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 Jun  5 02:28:54 2009
@@ -258,7 +258,7 @@
     String propName = property.getPropertyName();
     String propClass = property.getPropertyClass();
     String propVar = "_" + propName;
-    
+   
     if (property.isVirtual())
     {
       _writeVirtualSetMethod(out, componentClass, propName);
@@ -297,6 +297,12 @@
       _writeSetKnownTypeList (out, componentClass, propName, 
                      property.getPropertyClassParameters()[0]);
     }
+    else if (GeneratorHelper.isKnownTypeSet(propClass,  
+                                    property.getPropertyClassParameters()))
+    {
+      _writeSetKnownTypeSet (out, componentClass, propName, 
+                     property.getPropertyClassParameters()[0]);
+    }
     else if (GeneratorHelper.isConverter(propClass))
     {
       _writeSetConverter(out, componentClass, propName);
@@ -912,6 +918,62 @@
     }
   }
 
+  private void _writeSetKnownTypeSet(
+      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 ("_writeSetSet: propFullClass = " + propFullClass +
+                        " propClass= " + propClass + 
+                        " boxedClass=" + boxedClass);
+    if (_is12)
+    {
+      out.println("set" + boxedClass + "SetProperty" + 
+                  "(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.getStringSet(" + 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,



Mime
View raw message