|
From: Benoit X. <bx...@ob...> - 2007-08-08 00:05:42
|
The issue seems to be related to the Spring BeanWrapper! (I=92m using =
Spring
2.0.6)
public static void main(String[] a) {
IntSuper1 intSuper1 =3D new IntSuper1(123);
BeanWrapper bw =3D new BeanWrapperImpl(intSuper1);
=20
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++
++++");
System.out.println("name is of type:" + =
bw.getPropertyType("name"));
System.out.println("id is of type:" + bw.getPropertyType("id"));
=20
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++
++++");
=20
}
=20
This returns the same value (incorrect imho)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
name is of type:class java.lang.String
id is of type:class java.lang.Object
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
=20
Same if I use a generic directly like Super1<Integer> it still returns
Object as the type of =93id=94.
=20
Any suggestion apart from jumping off Tower Bridge?
=20
Thanks
=20
Benoit
=20
From: spr...@li...
[mailto:spr...@li...] On Behalf =
Of
Benoit Xhenseval
Sent: 08 August 2007 00:56
To: spr...@li...
Subject: [Springframework-rcp-dev] Serious FieldMetaData issue with
generics? Test included.
Importance: High
=20
Dear All,
=20
I'm faced with what I believe is a serious issue in Spring RC.
=20
I enclose an example of a typical code that I now face following some
refactoring.
Basically my method getId() used to return int and now is returning =
Integer.
No sweat one would say but ALL forms fails on trying to convert Object =
to
String and String to Object!
=20
java.lang.IllegalArgumentException: No converter registered to convert =
from
sourceClass 'class java.lang.String' to target class 'class
java.lang.Object'
at
org.springframework.binding.convert.support.GenericConversionService.getC=
onv
ersionExecutor(GenericConversionService.java:145)
at
org.springframework.binding.form.support.AbstractFormModel.createConverti=
ngV
alueModel(AbstractFormModel.java:350)
at
org.springframework.binding.form.support.AbstractFormModel.getValueModel(=
Abs
tractFormModel.java:294)
at
org.springframework.richclient.form.binding.support.AbstractBinding.getVa=
lue
Model(AbstractBinding.java:114)
at
org.springframework.richclient.form.binding.swing.TextComponentBinding.do=
Bin
dControl(TextComponentBinding.java:39)
at
org.springframework.richclient.form.binding.support.AbstractBinding.creat=
eCo
ntrol(AbstractBinding.java:75)
at
org.springframework.richclient.factory.AbstractControlFactory.getControl(=
Abs
tractControlFactory.java:85)
at
org.springframework.richclient.form.binding.support.AbstractBindingFactor=
y.i
nterceptBinding(AbstractBindingFactory.java:92)
at
org.springframework.richclient.form.binding.support.AbstractBindingFactor=
y.c
reateBinding(AbstractBindingFactory.java:70)
at
org.springframework.richclient.form.binding.support.AbstractBindingFactor=
y.c
reateBinding(AbstractBindingFactory.java:55)
at
org.springframework.richclient.form.builder.AbstractFormBuilder.createDef=
aul
tBinding(AbstractFormBuilder.java:78)
at
org.springframework.richclient.form.builder.TableFormBuilder.add(TableFor=
mBu
ilder.java:109)
at
org.springframework.richclient.form.builder.TableFormBuilder.add(TableFor=
mBu
ilder.java:85)
at
net.objectlab.springtest.TestForm.createFormControl(TestForm.java:22)
=20
The issue relates to the use of generics.
=20
The output for the example below is:
=20
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
name is of type:class java.lang.String
id is of type:class java.lang.Object
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
=20
I would have expected "id" to be of type java.lang.Integer.
=20
Has anyone faced this issue? Did you manage to find a workaround???=20
Please please! I will also investigate the code in FielMetaData to try =
to
figure out what is happening.
=20
Many thanks!!
=20
Benoit
=20
----------------
=20
import org.springframework.binding.form.FormModel;
import org.springframework.richclient.form.FormModelHelper;
=20
public class GenericTest {
public static void test() {
IntSuper1 intSuper1 =3D new IntSuper1(123);
FormModel model =3D FormModelHelper.createFormModel(intSuper1);
=20
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++
++++");
System.out.println("name is of type:" +
model.getFieldMetadata("name").getPropertyType());
System.out.println("id is of type:" +
model.getFieldMetadata("id").getPropertyType());
=20
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++
++++");
}
=20
private static class Super1<T> {
T id;
=20
public Super1(T id) {
this.id =3D id;
}
=20
public T getId() {
return id;
}
=20
public void setId(T id) {
this.id =3D id;
}
}
=20
private static class IntSuper1 extends Super1<Integer> {
private String name;
=20
public IntSuper1(Integer id) {
super(id);
}
=20
public String getName() {
return name;
}
=20
public void setName(String name) {
this.name =3D name;
}
}
}
=20
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: =
06/08/2007
16:53
=20
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: =
06/08/2007
16:53
No virus found in this outgoing message.
Checked by AVG Free Edition.=20
Version: 7.5.476 / Virus Database: 269.11.8/940 - Release Date: =
06/08/2007
16:53
=20
|