FieldGroup, Beans inside beans and ListSelect -or Select-

Hi,

I’m developing a form to edit my objects:


public class FuncionalidadVE {
	private String funcionalidad;
	private String descripcion;
}
public class PerfilVE {
	private int perfil;
	private String descripcion;
	private List<FuncionalidadVE> funcionalidades = new ArrayList<FuncionalidadVE>();
}

The complete list of FuncionalidadVE is loaded from DB, but the PerfilVE.funcionalidades only contains some of them.

I’ve managed to get working the FieldGroup, but I can´t get to work the funcionalidades.


		binder.setFieldFactory(new FieldGroupFieldFactory() {
			private DefaultFieldGroupFieldFactory defaultFactory = new DefaultFieldGroupFieldFactory();
			@Override
			public <T extends Field> T createField(Class<?> dataType, Class<T> fieldType) {
				System.out.println("CREATEFIELD :: dataType : " + dataType + " :: fieldType : " + fieldType);
				if ("java.util.List".equals(dataType.getName())) {
					BeanItemContainer<FuncionalidadVE> containerFuncionalidades = new BeanItemContainer<FuncionalidadVE>(FuncionalidadVE.class);
					containerFuncionalidades.addAll(AdministracionLogica.getInstance().getFuncionalidades());
					Field field = new ListSelect("Funcionalidades", containerFuncionalidades);
					((ListSelect) field).setItemCaptionPropertyId("descripcion");
					((ListSelect) field).setNullSelectionAllowed(true);
					((ListSelect) field).setMultiSelect(true);
					return fieldType.cast(field);
				}
				
				return defaultFactory.createField(dataType, fieldType);
			}
		});
		binder.setItemDataSource(item);

		layout.addComponent(binder.buildAndBind("perfil"));
		layout.addComponent(binder.buildAndBind("descripcion"));
		layout.addComponent(binder.buildAndBind("funcionalidades"));

I’ve made a new FieldGroupFieldFactory, but when I try to use it I receive this error:

I haven’t found any example of this complex data binding, only with simple POJO.

Thanks!!

You have to write your own Converter. See
Changing Default Converter