Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

TUTORIALVaadin lets you build secure, UX-first PWAs entirely in Java.
Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Calling javascript synchronously by Enver Haase, 1 month ago
Editable table and BeanItemContainer
Hi,
I don't know, how to propagate changes from editable table to database - where to place the code for persisting all changed rows from the table, neither how to recognize which rows was changed.
Thanks for Your help.
@SpringView(name = "clientList")
public class ClientList extends VerticalLayout implements View {
@Autowired
private ClientDAO clientDao;
private Table table;
private BeanItemContainer<Client> data;
@PostConstruct
public void init() {
data = new BeanItemContainer(Client.class);
data.addAll(clientDao.findAll());
table = new Table();
table.setContainerDataSource(data);
table.setEditable(false);
table.setImmediate(true);
bEditSave = new Button("Edit");
bEditSave.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
if (table.isEditable()) {
//save
bEditSave.setCaption("Edit");
table.commit();
} else {
bEditSave.setCaption("Save");
}
table.setEditable(!table.isEditable());
}
});
addComponent(table);
}
}
Last updated on
You cannot reply to this thread.