BeanFieldGroup. Field name of POJO in the method createField

Hey everyone, I need help!
I need to get a field name of my POJO (generic type E) in the method createField.
How can I do it?


private Layout getForm(E object) {
    binder = new BeanFieldGroup<E>(clazz);
    binder.setFieldFactory(new DefaultFieldGroupFieldFactory() {

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Override
    public <F Field> F createField(Class<?> dataType, Class<F> fieldType) {
if (Set.class.isAssignableFrom(dataType)) {
java.lang.reflect.Field field = clazz.getDeclaredField("current field name of POJO");
ParameterizedType type = (ParameterizedType) field.getGenericType();
            Class<?> classOfSet = (Class<?>) type.getActualTypeArguments()[0]
;

// SetField — it's a CustomField component
  // public class SetField<E extends BaseEntity> extends CustomField<Set<E>> {...}
  return new SetField(classOfSet);
        } else {
            return super.createField(dataType, fieldType);
        }
    }
});

Hi,

I think it is not available in new FieldFactories in V7 :frowning: Related issue in our trac: http://dev.vaadin.com/ticket/9748

If you are autogenerating your form views in V7, my suggestion is to use the old Form (and its FormFieldFactory) although it is nowadays deprecated.

cheers,
matti

Thank you for your answer!
I’m trying it.