我创建了带有可编辑表格和提交按钮的表单:
@Override
protected void populateItem(final Item<Game> listItem) {
final Game game = listItem.getModelObject();
listItem.setModel(new CompoundPropertyModel<Game>(game));
listItem.add(new TextField("players", Model.of(game.getPlayerResult().getPlayer().getName() + ":"
+ game.getOpponent().getPlayer().getName())));
listItem.add(new TextField("leftSide", Model.of(game.getResult().getLeftSide())));
listItem.add(new TextField("rightSide", Model.of(game.getResult().getRightSide())));
listItem.add(new CheckBox("overtime", Model.of(game.getResult().getOvertime())));
}
现在我想保存我插入的新值,但是当我调用时:
add(new Button("submit") {
private static final long serialVersionUID = 1L;
@Override
public void onSubmit() {
Iterator<Item<Game>> a = dataView.getItems();
while (a.hasNext()) {
Game game = a.next().getModelObject();
System.out.println(game.getPlayerResult().getPlayer().getName());
}
setResponsePage(new SchedulePage(tournament, table));
}
});
它仍然打印旧值。那么如何获得具有新值的表格呢?