You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2008/06/19 19:29:25 UTC

svn commit: r669582 - in /wicket/trunk/wicket/src/main/java/org/apache/wicket/util: convert/ConverterLocator.java lang/Objects.java

Author: ivaynberg
Date: Thu Jun 19 10:29:25 2008
New Revision: 669582

URL: http://svn.apache.org/viewvc?rev=669582&view=rev
Log:
WICKET-1706

Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java
    wicket/trunk/wicket/src/main/java/org/apache/wicket/util/lang/Objects.java

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java?rev=669582&r1=669581&r2=669582&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/convert/ConverterLocator.java Thu Jun 19 10:29:25 2008
@@ -96,7 +96,9 @@
 
 			try
 			{
-				return Objects.convertValue(value, theType);
+				// FIXME figure out what to do here. if the object cannot be converted to the type
+				// then either it becomes null or classcastexception. see WICKET-1706. */
+				return (X)Objects.convertValue(value, theType);
 			}
 			catch (Exception e)
 			{
@@ -115,7 +117,7 @@
 				return "";
 			}
 
-			return Objects.convertValue(value, String.class);
+			return (String)Objects.convertValue(value, String.class);
 		}
 	}
 

Modified: wicket/trunk/wicket/src/main/java/org/apache/wicket/util/lang/Objects.java
URL: http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/util/lang/Objects.java?rev=669582&r1=669581&r2=669582&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/util/lang/Objects.java (original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/util/lang/Objects.java Thu Jun 19 10:29:25 2008
@@ -621,9 +621,6 @@
 	 * This method also detects when arrays are being converted and converts the components of one
 	 * array to the type of the other.
 	 * 
-	 * @param <T>
-	 *            type to convert to
-	 * 
 	 * @param value
 	 *            an object to be converted to the given type
 	 * @param toType
@@ -631,7 +628,7 @@
 	 * @return converted value of the type given, or value if the value cannot be converted to the
 	 *         given type.
 	 */
-	public static <T> T convertValue(Object value, Class<T> toType)
+	public static Object convertValue(final Object value, final Class<?> toType)
 	{
 		Object result = null;
 
@@ -703,7 +700,7 @@
 				result = primitiveDefaults.get(toType);
 			}
 		}
-		return toType.cast(result);
+		return (result != null) ? result : value;
 	}
 
 	/**