Binding a Parameterized Type

2 views
Skip to first unread message

Mike Dorsey

unread,
Jul 28, 2010, 11:28:27 PM7/28/10
to GWT Pectin
Let's say I have a complex form widget which implements
HasValue<List<String>>.

Is it possible to create a FieldModel<List<String>> where the
parameterized type List<String> is bound to my BeanModelProvider?

I can't figure out how to do this since I must pass the .class type to
the fieldOfType function in my FormModel. For example:

// This works great...
FieldModel<String> fieldModel1;
this.fieldModel1 = fieldOfType(String.class).boundTo(myBeanProvider,
"fieldModel1");

// But what do I put in fieldOfType here?
FieldModel<List<String>> fieldModel2;
this.fieldModel2 = fieldOfType(???).boundTo(myBeanProvider,
"fieldModel2");

Andrew

unread,
Jul 28, 2010, 11:50:06 PM7/28/10
to GWT Pectin
Hi Mike,

This is something pectin doesn't have at this point and that would
likely need something like Guice's TypeLiteral.

However, in the specific case you mentioned could you use a ListModel
instead?

i.e. listOfType(String.class).boundTo(myBeanProvider,
"propertyThatsAList");

You can still bind this to a HasValue<Collection<String>>.

Cheers

Mike Dorsey

unread,
Jul 29, 2010, 10:27:02 AM7/29/10
to gwt-pecti...@googlegroups.com
Thanks a lot.  I forgot about the ListModel.  That worked perfectly.
--
Mike Dorsey
Reply all
Reply to author
Forward
0 new messages