1
爲什麼我得到這個錯誤,我已經嘗試了所有的命名規則(小寫/大寫)ID必須存在於容器或作爲生成列,缺少ID:ID
我使用Vaadin任何想法,這裏是我的代碼片段:
public class Usercontainer extends BeanItemContainer<Users> implements Serializable{
public static final Object[] NATURAL_COL_ORDER = new Object[] {"id", "empCode"};
public static final String[] COL_HEADERS_ENGLISH = new String[] {"User Id", "Emp code"};
public Usercontainer() throws IllegalArgumentException {
super(Users.class);
}
public static Usercontainer createTestData(){
Usercontainer users = null;
try
{
users = new Usercontainer();
for(int i=0; i<10;i++){
Users user = new Users();
user.setId(i*10);
user.setEmpcode("C00"+i);
users.addItem(user);
}
}
catch(Exception e){System.out.println("Error :"+e.getMessage());}
return users;
}
}
@Entity
@Table(name="_user")
public class Users {
//private String name;
public int id;
public String empcode;
@Id
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getEmpcode() {
return empcode;
}
public void setEmpcode(String empcode) {
this.empcode = empcode;
}
}
public class UserTable extends Table {
public UserTable(App1Application app){
setSizeFull();
setContainerDataSource(app.getDataSource());
setVisibleColumns(Usercontainer.NATURAL_COL_ORDER);
setColumnHeaders(Usercontainer.COL_HEADERS_ENGLISH);
this.setColumnReorderingAllowed(true);
setSelectable(true);
setImmediate(true);
addListener((Property.ValueChangeListener)app);
setNullSelectionAllowed(false);
}
}
這看起來應該工作。 我會打開異常斷點並查看它的比較結果。 看@你的Usercontainer類,並確保它在container.model –
中有正確的屬性app.getDataSource()在UserTable的構造函數中返回正確的對象嗎? – miq