Hi,
This patch is intended to Turbine 2 code, I know the class BaseValueParser is moved to
Fulcrum, but maybe you can consider it, in the migration process of Turbine 2 to
Fulcrum.
DESCRIPTION
The problem ocurrs when you try to set a DateKey property using the BaseValueParser.
For example:
data.setProperty( myObject );
And myObject have a DateKey property.
Edgar Gonzalez
Index: BaseValueParser.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-2/src/java/org/apache/turbine/util/parser/BaseValueParser.java,v
retrieving revision 1.2
diff -u -r1.2 BaseValueParser.java
--- BaseValueParser.java 15 Nov 2001 23:11:55 -0000 1.2
+++ BaseValueParser.java 4 Feb 2002 23:15:08 -0000
@@ -75,6 +75,7 @@
import org.apache.turbine.om.NumberKey;
import org.apache.turbine.om.StringKey;
+import org.apache.turbine.om.DateKey;
import org.apache.turbine.services.resources.TurbineResources;
@@ -1195,6 +1196,31 @@
}
/**
+ * Return an DateKey for the given name. If the name does not
+ * exist, return null.
+ *
+ * @param name A String with the name.
+ * @return A DateKey, or <code>null</code> if unparsable.
+ */
+ public DateKey getDateKey(String name)
+ {
+ try
+ {
+ String value = null;
+ Object object = parameters.get(convert(name));
+ if (object != null)
+ {
+ value = ((String[])object)[0];
+ }
+ return (StringUtils.isValid(value) ? new DateKey(value) : null);
+ }
+ catch ( ClassCastException e )
+ {
+ return null;
+ }
+ }
+
+ /**
* Uses bean introspection to set writable properties of bean from
* the parameters, where a (case-insensitive) name match between
* the bean property and the parameter is looked for.
@@ -1361,6 +1387,10 @@
else if (propclass == StringKey.class)
{
args[0] = getStringKey(prop.getName());
+ }
+ else if (propclass == DateKey.class)
+ {
+ args[0] = getDateKey(prop.getName());
}
else
{