我很新vaadin(和java)。vaadin,试图将项目添加到sqlContainer时获得空指针
我有了像这样的SQLcontainer一个表:
public class ProjectTable extends Table {
public ProjectTable(final DocumentmanagerApplication app) {
setSizeFull();
setContainerDataSource(app.getDbHelp().getProjectContainer());
setImmediate(true);
commit();
setSelectable(true);
}
}
我有一个按钮和一个文本字段,在表中填写的数据
public void buttonClick(ClickEvent event)
{
SQLContainer cont = h.getAssetContainer();
String dataResult = tf.getValue().toString(); // TEXT FIELD
System.out.println(dataResult);
Object itemId = cont.addItem(); // cont is the container
**cont.getContainerProperty(itemId , "id").setValue(dataResult); // BUG IS HERE !!! **
try {
cont.commit();
} catch (UnsupportedOperationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我不断收到一个“空指针例外“,不管我做什么。上线** cont.getContainerProperty(itemId,“id”)。setValue(dataResult);
我做错了什么?什么是空指针?
如果有什么不清楚的地方,请通知我。
请帮忙,在此先感谢。
容器得到一个空指针异常.getContainerPropertyIds也有空指针问题。 :(我没有任何线索为什么是这样或是怎么回事但是。itemId不为空,(检查它) – 2012-08-16 05:52:45
容器不包含项目“itemId”*或*对象“itemId”doesn' t有一个属性'id',这是返回null的规则,'getContainerPropertyIds'不应该返回null,而应该是一个空列表(在最坏的情况下) – 2012-08-16 06:07:50