当我使用带有BeanItemContainer的Vaadin网格时,我遇到了一些问题。它显示一行OK,但是当我尝试保存已编辑的行时,它会抛出:
score = raw_input('what is your score?')
try:
score = float(score)
except:
score = -1
print 'Bad Score, Try Again'
if score >= 0.9:
print "A"
elif score >= 0.8:
print "B"
elif score >= 0.7:
print "C"
elif score >= 0.6:
print "D"
if score < 0.6:
print "F"
然后,如果我再次点击保存按钮,它会抛出:
java.lang.IllegalArgumentException: Given item id (uz.sample.backend.entity.MyBean@4d949367) does not exist in the container
at com.vaadin.ui.Grid$AbstractSelectionModel.checkItemIdExists(Grid.java:1367)
at com.vaadin.ui.Grid$SingleSelectionModel.select(Grid.java:1457)
at com.vaadin.ui.Grid$SingleSelectionModel$1.select(Grid.java:1442)
我的代码是这样的:
com.vaadin.data.fieldgroup.FieldGroup$CommitException: Property "organConductedCourse" not bound to datasource. at com.vaadin.data.fieldgroup.FieldGroup.startTransactions(FieldGroup.java:557) at com.vaadin.data.fieldgroup.FieldGroup.commit(FieldGroup.java:476) at com.vaadin.ui.Grid.saveEditor(Grid.java:6817) at com.vaadin.ui.Grid$4.save(Grid.java:4782)
我不知道我在哪里做错了。也许你有任何想法。谢谢你的任何建议!
答案 0 :(得分:1)
经过一番搜索,我找到了答案。我必须使用BeanContainer
而不是BeanItemContainer
。事实证明BeanItemContainer
使用每个Item的hashCode来标识该项。因此,MyBean
&#39; s hashCode()
基于编辑后更改的字段。然后找不到项目,&#34;项目ID不存在于容器中&#34;错误被抛出。(因为没有人回答这个问题,我把我的评论作为答案的解决方案,我希望它能帮助别人)