CustomField needed ?

public class User {
private String name;
private String password;
private List roles;

Should editing this user with a form work or is it necessary to use a CustomField?

I am asking because I get am gettig this during form.commit():
Caused by: java.lang.NoSuchMethodException: java.util.List.(java.lang.String)
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getConstructor(Class.java:1657)
at com.vaadin.data.util.MethodProperty.setValue(MethodProperty.java:718)

Thanks,
Roland

A standard multi-select component such as a TwinColSelect for the role list returns a Set of item identifiers as its value, whereas you want a List. Even if using a BeanItemContainer for the selection component (where the identifiers are the beans themselves), the value is a Set and not a List.Therefore, you need to perform conversions.

The easiest way to do this is probably using FieldWrapper from the CustomField add-on.

There are also some helper classes you could look at as a basis for ID<->bean conversions, e.g.
EntitySetFieldWrapper
and
EntityFieldWrapper
used by the Roo addon.

Usage in your form field factory:

TwinColSelect select = new TwinColSelect(null, roleContainer);
select.setMultiSelect(true);
select.setItemCaptionPropertyId("rolename");
field = new EntitySetFieldWrapper<Role>(select, Role.class, roleContainer, "id");

This uses a Set as the underlying data structure and JPAContainer as RoleContainer, but should be easy to adapt for a List and BeanItemContainer/BeanContainer.

I hope I might be able to move these and more to an add-on sometime in the future.

I have the same issue. Does the add-on already exists?

Some such utility classes are in the add-on
CustomField Utils
, which also depends on the original
CustomField add-on
.