You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2009/02/24 19:43:29 UTC

svn commit: r747483 - /myfaces/trinidad/branches/1.2.10.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java

Author: gcrawford
Date: Tue Feb 24 18:43:29 2009
New Revision: 747483

URL: http://svn.apache.org/viewvc?rev=747483&view=rev
Log:
TRINIDAD-1407 DateTimeConverter doesn't convert correctly as per the expectedDataType

Sometimes the valueExpression's expectedType is just object, so use type instead.

Modified:
    myfaces/trinidad/branches/1.2.10.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java

Modified: myfaces/trinidad/branches/1.2.10.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.10.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java?rev=747483&r1=747482&r2=747483&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.10.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java (original)
+++ myfaces/trinidad/branches/1.2.10.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/convert/DateTimeConverter.java Tue Feb 24 18:43:29 2009
@@ -6,9 +6,9 @@
  *  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
@@ -56,7 +56,7 @@
  * pushes all relevant information to the client side so that conversion can be
  * enabled at the client side.
  * </p>
- * 
+ *
  * @version $Name: $ ($Revision:
  *          adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/convert/DateTimeConverter.java#0 $)
  *          $Date: 10-nov-2005.19:06:22 $
@@ -121,6 +121,14 @@
     if (expression != null)
     {
       Class<?> expectedType = expression.getExpectedType();
+
+      // If the expectedType is Object ask for the type which may be more specific
+      if(expectedType == Object.class)
+      {
+        expectedType = expression.getType(context.getELContext());
+      }
+
+
       // Sometimes the type might be null, if it cannot be determined:
       if ((expectedType != null)
           && (!expectedType.isAssignableFrom(value.getClass())))
@@ -150,8 +158,8 @@
             Throwable cause = e.getCause();
             if (cause == null)
               cause = e;
-           
-            FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, 
+
+            FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR,
                                                 MessageFactory.getString(context, UIXEditableValue.CONVERSION_MESSAGE_ID),
                                                 cause.getLocalizedMessage());
             throw new ConverterException(msg, e);
@@ -171,8 +179,8 @@
       _LOG
           .severe("The component is null, but it is needed for the client id, so no script written");
       return null;
-    }    
-        
+    }
+
     // Add a JavaScript Object to store the datefield formats
     // on the client-side. We currently store the format string
     // for each and every field. It'd be more efficient to have
@@ -257,7 +265,7 @@
             component);
         detailMessage = XhtmlLafUtils.escapeJS(msg.getDetail());
       }
-      
+
       String exampleString = XhtmlLafUtils.escapeJS(getExample(context));
       String escapedType = XhtmlLafUtils.escapeJS(getType().toUpperCase());
 
@@ -269,7 +277,7 @@
       {
         outBuffer.append(",'");
         outBuffer.append (loc.toString());
-        outBuffer.append ("','");        
+        outBuffer.append ("','");
       }
       else
       {
@@ -284,8 +292,8 @@
       {
         messages.put("detail", detailMessage);
         messages.put("hint", hintFormat);
-        outBuffer.append(','); 
-        
+        outBuffer.append(',');
+
         try
         {
           JsonUtils.writeMap(outBuffer, messages, false);
@@ -529,7 +537,7 @@
     XhtmlUtils.escapeJS(buffer, pattern);
     buffer.append('\'');
   }
-  
+
   private String _getHint()
   {
     String type = getType();
@@ -541,7 +549,7 @@
     {
       return getHintBoth();
     }
-    else 
+    else
     {
       return getHintTime();
     }
@@ -564,7 +572,7 @@
     }
     return buffer.toString();
   }
-  
+
   private String _getLocaleString (FacesContext context)
   {
     Locale dateTimeConverterLocale = getLocale();
@@ -582,7 +590,7 @@
         return (sb.toString());
       }
     }
-    return "null";    
+    return "null";
   }
 
   // Bug 4570591