View Full Version : Bad generics in MultiField

23 Feb 2009, 9:06 AM

I'm not sure to see why there is the F type parameter in MultiField class. If we use it, we can only add one type of field in a MultiField.
Also, MultiField<F extends Field> extends Field<F> means that MultiFields handle a value the type of which is Field and I don't think anoyone wants to keep a value the type of which is Field in a Field.
So I suggest :

MultiField<F extends Field> extends Field<F>to be replaced by

MultiField<D> extends Field<D>

24 Feb 2009, 11:58 AM
well, I guess the MultiField is ok for Combo- and Radiogroups.

But I would also like to have another version without this restriction, much like your suggestion:
it would be nice to have a BaseMultiField that could handle different Fields for one type of data:
e.g. I want to have a DateTimeField that has datatype Date and internally has 2 fields: 1 DateField and one TimeField

what is now MultiField could become this

public class BaseMultiField<D> extends Field<D> {

protected List<Field<?>> fields;
then the new MultiField could extend this new class:

public class MultiField<D> extends BaseMultiField<Field<D>> {
and my date-time field would look like this:

public class DateTimeField extends BaseMultiField<Date> {

private final TimeField timeField;
private final DateField dateField;

public DateTimeField() {
dateField = new DateField();
timeField = new TimeField();

public Date getValue() {
Date result = dateField.getValue();
if (result == null) {
return null;
return DateHelper.addTimeToDate(result, timeField.getValue());

public void setValue(Date value) {

27 Mar 2009, 12:01 AM
@Ext team : what do you think of it ? Can we expect a fix for 2.0 release ?

1 Apr 2009, 8:41 AM
+1 (and basically +1 for all generics fixes)

5 May 2009, 1:08 AM
Well, I've writed my own MultiField. I've just changed the declaration :

public class MultiField<D> extends Field<D>and replaced F occurences by Field<?>.

It works well.

8 May 2009, 6:07 AM
We have changed MultiField to this:

public class MultiField<D> extends Field<D>Change is in SVN for 2.0.

12 May 2009, 3:35 AM
Thanks Darell.

These changes would also be greatly appreciated :
(especially the latter)