我为什么会遇到此错误的任何想法,我尝试了所有命名约定(小写/大写)
我正在使用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);
}
}
最佳答案
如果在"empCode"
中使用NATURAL_COL_ORDER
,则应在实体类(而不是getEmpCode()
)imho中使用getEmpcode()
getter方法。