diff --git a/add-on/src/main/java/org/vaadin/crudui/form/AbstractAutoGeneratedCrudFormFactory.java b/add-on/src/main/java/org/vaadin/crudui/form/AbstractAutoGeneratedCrudFormFactory.java index d2d80bd..c95a853 100644 --- a/add-on/src/main/java/org/vaadin/crudui/form/AbstractAutoGeneratedCrudFormFactory.java +++ b/add-on/src/main/java/org/vaadin/crudui/form/AbstractAutoGeneratedCrudFormFactory.java @@ -144,7 +144,7 @@ protected List buildFields(CrudOperation operation, T domain if (propertyType != null) { - HasValueAndElement field = buildField(configuration, property, propertyType); + HasValueAndElement field = buildField(configuration, property, propertyType, domainObject); if (field != null) { configureField(field, property, fieldCaption, readOnly, configuration); @@ -187,18 +187,18 @@ protected List buildFields(CrudOperation operation, T domain return fields; } - protected HasValueAndElement buildField(CrudFormConfiguration configuration, String property, Class propertyType) throws InstantiationException, IllegalAccessException { + protected HasValueAndElement buildField(CrudFormConfiguration configuration, String property, Class propertyType, T domainObject) throws InstantiationException, IllegalAccessException { HasValueAndElement field; - FieldProvider provider = configuration.getFieldProviders().get(property); + FieldProvider provider = (FieldProvider) configuration.getFieldProviders().get(property); if (provider != null) { - field = provider.buildField(); + field = provider.buildField(domainObject); } else { Class> fieldType = configuration.getFieldTypes().get(property); if (fieldType != null) { field = fieldType.newInstance(); } else { - field = new DefaultFieldProvider(propertyType).buildField(); + field = new DefaultFieldProvider(propertyType).buildField(domainObject); } } diff --git a/add-on/src/main/java/org/vaadin/crudui/form/FieldProvider.java b/add-on/src/main/java/org/vaadin/crudui/form/FieldProvider.java index 4287c73..38ee0ac 100644 --- a/add-on/src/main/java/org/vaadin/crudui/form/FieldProvider.java +++ b/add-on/src/main/java/org/vaadin/crudui/form/FieldProvider.java @@ -13,6 +13,6 @@ @FunctionalInterface public interface FieldProvider extends Serializable { - HasValueAndElement buildField(); + HasValueAndElement buildField(T t); } diff --git a/add-on/src/main/java/org/vaadin/crudui/form/impl/field/provider/AbstractListingProvider.java b/add-on/src/main/java/org/vaadin/crudui/form/impl/field/provider/AbstractListingProvider.java index ccf3dcb..7cc9962 100644 --- a/add-on/src/main/java/org/vaadin/crudui/form/impl/field/provider/AbstractListingProvider.java +++ b/add-on/src/main/java/org/vaadin/crudui/form/impl/field/provider/AbstractListingProvider.java @@ -38,7 +38,7 @@ public AbstractListingProvider(String caption, Collection items, ComponentRen } @Override - public HasValueAndElement, T> buildField() { + public HasValueAndElement, T> buildField(T t) { C field = buildAbstractListing(); field.setItems(items); return field; diff --git a/add-on/src/main/java/org/vaadin/crudui/form/impl/field/provider/DefaultFieldProvider.java b/add-on/src/main/java/org/vaadin/crudui/form/impl/field/provider/DefaultFieldProvider.java index abc5985..7e1b70f 100644 --- a/add-on/src/main/java/org/vaadin/crudui/form/impl/field/provider/DefaultFieldProvider.java +++ b/add-on/src/main/java/org/vaadin/crudui/form/impl/field/provider/DefaultFieldProvider.java @@ -23,7 +23,7 @@ public DefaultFieldProvider(Class type) { } @Override - public HasValueAndElement buildField() { + public HasValueAndElement buildField(Object t) { if (Boolean.class.isAssignableFrom(type) || boolean.class == type) { return new Checkbox(); }