Author: awiner
Date: Tue May  1 11:45:50 2007
New Revision: 534193

URL: http://svn.apache.org/viewvc?view=rev&rev=534193
Log:
ADFFACES-477: give deferred-values for "binding" and "converter"
 - Hardcode UIComponent and Converter types in the plugin for now
 - Fix the type of "binding" in the Trinidad metadata to be UIComponent
ADFFACES-476: add a <disableIdExpressions> configuration hook for turning off
   rtexprvalue on "id"
- Also update the Trinidad component generation to use getExpressionString() 
instead of
getValue(null), thereby bypassing coercion, for all types where Strings are 
processed
directly by the tag.
- And update the MyFaces component generation similarly, though just for 
converter
- Fix whitespace on trh-base.tld
- Add <coerceStrings> configuration hook for forcing java.lang.String coercion 
where
  absolutely necessary - it may be necessary to turn this on at a per-property 
level
  instead of just per-project, though

Modified:
    
incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
    
incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
    
incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java
    
incubator/adffaces/branches/faces-1_2-070427/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/javax/faces/Component.xml
    
incubator/adffaces/branches/faces-1_2-070427/trinidad/trinidad-impl/src/main/conf/META-INF/trh-base.tld

Modified: 
incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java?view=diff&rev=534193&r1=534192&r2=534193
==============================================================================
--- 
incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
 (original)
+++ 
incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/GenerateJspTaglibsMojo.java
 Tue May  1 11:45:50 2007
@@ -545,11 +545,21 @@
         {
           stream.writeCharacters("\n      ");
           stream.writeStartElement("deferred-value");
-          if (_CAN_COERCE.contains(property.getPropertyClass()))
+          String propertyClass = property.getPropertyClass();
+          // Writing java.lang.String is usually a bad idea - it
+          // means that null gets coerced to the empty string.
+          if (("java.lang.String".equals(propertyClass) && coerceStrings) ||
+              _CAN_COERCE.contains(property.getPropertyClass()))
           {
             stream.writeCharacters("\n        ");
             stream.writeStartElement("type");
-            stream.writeCharacters(property.getPropertyClass());
+            // Trim out any use of generics here - since JSP coercion
+            // certainly can't do anything there
+            int genericIndex = propertyClass.indexOf('<');
+            if (genericIndex > 0)
+              propertyClass = propertyClass.substring(0, genericIndex);
+
+            stream.writeCharacters(propertyClass);
             stream.writeEndElement();
             stream.writeCharacters("\n      ");
           }
@@ -563,7 +573,7 @@
           // As of JSF 1.2, "id" can be set via an rtexprvalue (but
           // *not* by a ValueExpression) - it has to be evaluated
           // in the JSP
-          if ("id".equals(propertyName))
+          if ("id".equals(propertyName) && !disableIdExpressions)
             stream.writeCharacters("true");
           else
             stream.writeCharacters("false");
@@ -1748,6 +1758,17 @@
    */
   protected boolean force;
 
+
+  /**
+   * @parameter
+   */
+  protected boolean disableIdExpressions;
+
+  /**
+   * @parameter
+   */
+  protected boolean coerceStrings;
+
   
   /**
    * @parameter
@@ -1760,6 +1781,9 @@
     return (String)_RESOLVABLE_TYPES.get(className);
   }
 
+  // TODO: for everything but Locale, String[], Date, and TimeZone,
+  // in JSF 1.2 we should already be going through coercion, and
+  // not need any of the "TagUtils" functions
   static private Map _createResolvableTypes()
   {
     Map resolvableTypes = new HashMap();
@@ -1830,5 +1854,15 @@
     _CAN_COERCE.add("short");
     _CAN_COERCE.add("char");
     _CAN_COERCE.add("byte");
+
+    // See http://issues.apache.org/jira/browse/ADFFACES-477:  for
+    // "binding" and "converter" properties, we want the deferred-types
+    // there.  Hardcoding these here is very ugly, but putting in
+    // all coercion rules would break how Trinidad handles Dates,
+    // and Lists of Colors, etc. - for those, we want to support
+    // raw Strings (which the JSP engine doesn't know how to coerce)
+    // and coerce them ourselves in the tag.
+    _CAN_COERCE.add("javax.faces.component.UIComponent");
+    _CAN_COERCE.add("javax.faces.convert.Converter");
   }
 }

Modified: 
incubator/adffaces/branches/faces-1_2-070427/plugins/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/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java?view=diff&rev=534193&r1=534192&r2=534193
==============================================================================
--- 
incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
 (original)
+++ 
incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/MyFacesComponentTagGenerator.java
 Tue May  1 11:45:50 2007
@@ -492,14 +492,14 @@
       out.println("else");
       out.println("{");
       out.indent();
-      out.println("Object o = " + propVar + ".getValue(null);");
-      out.println("if (o != null)");
+      out.println("String s = " + propVar + ".getExpressionString();");
+      out.println("if (s != null)");
       out.println("{");
 
       out.indent();
       out.println("Converter converter = getFacesContext().getApplication().");
       out.indent();
-      out.println("createConverter(o.toString());");
+      out.println("createConverter(s);");
       out.unindent();
       out.println("comp.setConverter(converter);");
 

Modified: 
incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java?view=diff&rev=534193&r1=534192&r2=534193
==============================================================================
--- 
incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java
 (original)
+++ 
incubator/adffaces/branches/faces-1_2-070427/plugins/maven-faces-plugin/src/main/java/org/apache/myfaces/trinidadbuild/plugin/faces/generator/taglib/TrinidadComponentTagGenerator.java
 Tue May  1 11:45:50 2007
@@ -385,13 +385,13 @@
       out.println("else");
       out.println("{");
       out.indent();
-      out.println("Object o = " + propVar + ".getValue(null);");
-      out.println("if (o != null)");
+      out.println("String s = " + propVar + ".getExpressionString();");
+      out.println("if (s != null)");
       out.indent();
       out.println("VirtualAttributeUtils.setAccessKeyAttribute(");
       out.indent();
       out.println("bean,");
-      out.println("o.toString(),");
+      out.println("s,");
       out.println(propKeys[0] + ",");
       out.println(propKeys[1] + ");");
       out.unindent();
@@ -545,11 +545,11 @@
       out.println("else");
       out.println("{");
       out.indent();
-      out.println("Object val = " + propVar + ".getValue(null);");
-      out.println("if (val != null)");
+      out.println("String s = " + propVar + ".getExpressionString();");
+      out.println("if (s != null)");
       out.indent();
       out.println("bean.setProperty(" + componentClass + "." + propKey + ",");
-      out.println("Enum.valueOf(" + propClass + ".class,val.toString()));");
+      out.println("Enum.valueOf(" + propClass + ".class,s));");
       out.unindent();
       out.unindent();
       out.println("}");
@@ -604,11 +604,11 @@
       out.println("else");
       out.println("{");
       out.indent();
-      out.println("Object val = " + propVar + ".getValue(null);");
+      out.println("String val = " + propVar + ".getExpressionString();");
       out.println("if (val != null)");
       out.indent();
       out.println("bean.setProperty(" + componentClass + "." + propKey + ",");
-      out.println("\tKeyStroke.getKeyStroke(val.toString()));");
+      out.println("\tKeyStroke.getKeyStroke(val));");
       out.unindent();
       out.unindent();
       out.println("}");
@@ -662,11 +662,11 @@
       out.println("else");
       out.println("{");
       out.indent();
-      out.println("Object val = " + propVar + ".getValue(null);");
+      out.println("String val = " + propVar + ".getExpressionString();");
       out.println("if (val != null)");
       out.indent();
       out.println("bean.setProperty(" + componentClass + "." + propKey + ",");
-      out.println("\tAWTKeyStroke.getAWTKeyStroke(val.toString()));");
+      out.println("\tAWTKeyStroke.getAWTKeyStroke(val));");
       out.unindent();
       out.unindent();
       out.println("}");
@@ -720,15 +720,15 @@
       out.println("else");
       out.println("{");
       out.indent();
-      out.println("Object o = " + propVar + ".getValue(null);");
-      out.println("if (o != null)");
+      out.println("String s = " + propVar + ".getExpressionString();");
+      out.println("if (s != null)");
       out.indent();
       out.println("{");
       out.println("try");
       out.println("{");
       out.indent();
       out.println("bean.setProperty(" + componentClass + "." + propKey + ",");
-      out.println("                 TagUtils.getColorList(o.toString()));");
+      out.println("                 TagUtils.getColorList(s));");
       out.unindent();
       out.println("}");
       out.println("catch (ParseException pe)");
@@ -799,14 +799,14 @@
       out.println("else");
       out.println("{");
       out.indent();
-      out.println("Object o = " + propVar + ".getValue(null);");
-      out.println("if (o != null)");
+      out.println("String s = " + propVar + ".getExpressionString();");
+      out.println("if (s != null)");
       out.println("{");
 
       out.indent();
       out.println("Converter converter = getFacesContext().getApplication().");
       out.indent();
-      out.println("createConverter(o.toString());");
+      out.println("createConverter(s);");
       out.unindent();
       out.println("bean.setProperty(" + componentClass + "." + propKey + ", 
converter);");
 

Modified: 
incubator/adffaces/branches/faces-1_2-070427/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/javax/faces/Component.xml
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/branches/faces-1_2-070427/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/javax/faces/Component.xml?view=diff&rev=534193&r1=534192&r2=534193
==============================================================================
--- 
incubator/adffaces/branches/faces-1_2-070427/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/javax/faces/Component.xml
 (original)
+++ 
incubator/adffaces/branches/faces-1_2-070427/trinidad/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/javax/faces/Component.xml
 Tue May  1 11:45:50 2007
@@ -51,7 +51,7 @@
 bean.  This can be used to give programmatic access to a component
 from a backing bean, or to move creation of the component to a backing 
bean.</description>
       <property-name>binding</property-name>
-      <property-class>javax.el.ValueExpression</property-class>
+      <property-class>javax.faces.component.UIComponent</property-class>
     </property>
     <property>
       <property-name>transient</property-name>

Modified: 
incubator/adffaces/branches/faces-1_2-070427/trinidad/trinidad-impl/src/main/conf/META-INF/trh-base.tld
URL: 
http://svn.apache.org/viewvc/incubator/adffaces/branches/faces-1_2-070427/trinidad/trinidad-impl/src/main/conf/META-INF/trh-base.tld?view=diff&rev=534193&r1=534192&r2=534193
==============================================================================
--- 
incubator/adffaces/branches/faces-1_2-070427/trinidad/trinidad-impl/src/main/conf/META-INF/trh-base.tld
 (original)
+++ 
incubator/adffaces/branches/faces-1_2-070427/trinidad/trinidad-impl/src/main/conf/META-INF/trh-base.tld
 Tue May  1 11:45:50 2007
@@ -1,30 +1,30 @@
-<?xml version = "1.0" ?>
-<!--
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
-          
--->
+<?xml version = "1.0" ?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+          
+-->
 <taglib
   xmlns="http://java.sun.com/xml/ns/javaee";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd";
   version="2.1">
-  <display-name>Apache Trinidad HTML</display-name>
-  <tlib-version>11-m3</tlib-version>
-  <short-name>trh</short-name>
-  <uri>http://myfaces.apache.org/trinidad/html</uri>
-</taglib>
+  <display-name>Apache Trinidad HTML</display-name>
+  <tlib-version>11-m3</tlib-version>
+  <short-name>trh</short-name>
+  <uri>http://myfaces.apache.org/trinidad/html</uri>
+</taglib>


Reply via email to