我正在開發一個vaadin應用程序,現在我無法解決以下問題。ID必須存在於容器中或作爲生成的列
我有我的對象模型:
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;
}
}
現在,我想這個對象的BeanItemContainer
綁定這樣:
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);
,但我得到這個錯誤:
Ids must exist in the Container or as a generated column, missing id: dValidoAl
我在哪裏做錯了?
'tableContainer.getContainerPropertyIds()'返回什麼?那裏有'dValidoAl'嗎? –
我在tableContainer.getContainerPropertyIds()中發現了DValidoAl而不是dValidoAl,並且我用「DValidoAl」更改了屬性「dValidoAl」的名稱,現在一切正常。謝謝 – Skizzo
@Skizzo請將您的解答作爲答覆並接受它!謝謝! – Krayo