Reputation: 2983
I'm developing an vaadin application, and now I'm not able to resolve the following problem.
I have my object model:
public class MyModel {
private long id;
private Date dValidoAl;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Date getDValidoAl() {
return dValidoAl;
}
public void setDValidoAl(Date dValidoAl) {
this.dValidoAl = dValidoAl;
}
}
Now I'm trying to bind this object to a BeanItemContainer
in this way:
Table table = new Table();
BeanItemContainer<MyModel> container = new BeanItemContainer<MyModel>(MyModel.class);
table.setContainerDataSource(container);
Object[] visibleProperties = new Object[] { "id", "dValidoAl" };
String[] columnsHeader = new String[] { "Id", "Inizio Validità" };
table.setVisibleColumns(visibleProperties);
table.setColumnHeaders(columnsHeader);
but I get this error:
Ids must exist in the Container or as a generated column, missing id: dValidoAl
Where am I doing wrong?
Upvotes: 4
Views: 5243
Reputation: 489
As @Skizzo posted, and as defined in the Book of Vaadin, the BeanItemContainer (implementation of BeanContainer) will take as PropertyIds inspecting the getters and setters.
The item properties are determined automatically by inspecting the getter and setter methods of the class. This requires that the bean class has public visibility, local classes for example are not allowed. Only beans of the same type can be added to the container.
In this case, applying DValidoAl as the propertyId of the container you can do the operations you need.
Upvotes: 1