|
From: <jue...@we...> - 2004-06-14 12:15:34
|
This is a post-1.0.2 bug that I've accidentally introduced last week. =
I've just fixed it. Thanks for spotting this!
Juergen
-----Original Message-----
From: spr...@li...
[mailto:spr...@li...]On Behalf
Of Tom Turelinckx
Sent: Monday, June 14, 2004 12:33 PM
To: spr...@li...
Subject: Re: Fw: [Springframework-developer] BeanWrapperImpl abstraction
Juergen,
> The change should be completely backward-compatible. Only if you
> specified a
> wrong type on registration (i.e. not the target type that the editor =
will
> actually create), the stricter check will now show. As passing in such =
a
> wrong type is a misuse of the API, this is even desirable, I guess.
When you register a custom editor "for a certain type", do you register
it for the type of the property or the actual type of the value?
For example, I'm not sure this is desired behavior:
private void test() {
long now =3D 1087206665855L;
System.out.println(getValue(new Date(now), null));
// prints "14/06/2004"
System.out.println(getValue(new Timestamp(now), null));
// prints "2004-06-14 11:51:05.855"
// shouldn't this be "14/06/2004" as well?
System.out.println(getValue(new Timestamp(now), "date"));
// prints "14/06/2004"
}
private Object getValue(Date date, String property) {
DateBean dateBean =3D new DateBean();
dateBean.setDate(date);
DataBinder binder =3D new DataBinder(dateBean, "dateBean");
binder.registerCustomEditor(Date.class, property,
new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"),
true));
return binder.getErrors().getFieldValue("date");
}
public class DateBean {
private Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date =3D date;
}
}
Suppose I have a form in a web application to edit an object, with a
Controller extending from AbstractFormController. The form backing
object has java.util.Date properties, so I register a custom editor for
all Date properties (property =3D null) in initBinder, like above.
When the form backing object is the result of a database query, its
java.util.Date properties actually contain java.sql.Timestamp objects,
which are then incorrectly displayed in the form, because the property
editor is not used, unless I register a custom editor for every
individual property...
Of course, I don't want to _know_ that the Date properties are actually
Timestamps, so I don't want to register a custom editor for all
Timestamp properties...
Is this the intended behavior or a bug?
Kind regards,
Tom.
-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the
one installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|