|
From: Benoit X. <bx...@ob...> - 2007-08-07 23:56:33
|
Dear All,
I'm faced with what I believe is a serious issue in Spring RC.
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!
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.getConv
ersionExecutor(GenericConversionService.java:145)
at
org.springframework.binding.form.support.AbstractFormModel.createConvertingV
alueModel(AbstractFormModel.java:350)
at
org.springframework.binding.form.support.AbstractFormModel.getValueModel(Abs
tractFormModel.java:294)
at
org.springframework.richclient.form.binding.support.AbstractBinding.getValue
Model(AbstractBinding.java:114)
at
org.springframework.richclient.form.binding.swing.TextComponentBinding.doBin
dControl(TextComponentBinding.java:39)
at
org.springframework.richclient.form.binding.support.AbstractBinding.createCo
ntrol(AbstractBinding.java:75)
at
org.springframework.richclient.factory.AbstractControlFactory.getControl(Abs
tractControlFactory.java:85)
at
org.springframework.richclient.form.binding.support.AbstractBindingFactory.i
nterceptBinding(AbstractBindingFactory.java:92)
at
org.springframework.richclient.form.binding.support.AbstractBindingFactory.c
reateBinding(AbstractBindingFactory.java:70)
at
org.springframework.richclient.form.binding.support.AbstractBindingFactory.c
reateBinding(AbstractBindingFactory.java:55)
at
org.springframework.richclient.form.builder.AbstractFormBuilder.createDefaul
tBinding(AbstractFormBuilder.java:78)
at
org.springframework.richclient.form.builder.TableFormBuilder.add(TableFormBu
ilder.java:109)
at
org.springframework.richclient.form.builder.TableFormBuilder.add(TableFormBu
ilder.java:85)
at
net.objectlab.springtest.TestForm.createFormControl(TestForm.java:22)
The issue relates to the use of generics.
The output for the example below is:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
name is of type:class java.lang.String
id is of type:class java.lang.Object
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I would have expected "id" to be of type java.lang.Integer.
Has anyone faced this issue? Did you manage to find a workaround???
Please please! I will also investigate the code in FielMetaData to try to
figure out what is happening.
Many thanks!!
Benoit
----------------
import org.springframework.binding.form.FormModel;
import org.springframework.richclient.form.FormModelHelper;
public class GenericTest {
public static void test() {
IntSuper1 intSuper1 = new IntSuper1(123);
FormModel model = FormModelHelper.createFormModel(intSuper1);
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());
System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++");
}
private static class Super1<T> {
T id;
public Super1(T id) {
this.id = id;
}
public T getId() {
return id;
}
public void setId(T id) {
this.id = id;
}
}
private static class IntSuper1 extends Super1<Integer> {
private String name;
public IntSuper1(Integer id) {
super(id);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
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
|