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, 3 weeks ago
Disable table write through when used as field in form
I would like to use a table as a field inside a form, but I would like to disable write through to the data source until commit is called on the form.
I am calling setWriteThrough(false) on both the table and form, but does not seem to work.
I am using 6.7.3
Here is an example of what I would like to do:
public class TabletestApplication extends Application {
private Bean bean1;
private Table table;
@Override
public void init() {
Window mainWindow = new Window("Tabletest Application");
setMainWindow(mainWindow);
table = new Table();
table.setWriteThrough(false);
table.setEditable(true);
table.setContainerDataSource(createContainer());
final Form form = new Form();
form.setWriteThrough(false);
form.addField("Bean Table", table);
mainWindow.addComponent(form);
Button commitButton = new Button("Commit");
commitButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
System.out.println("Form is modified = " + form.isModified());
System.out.println("Table is modified = " + table.isModified());
System.out.println("Before commit: " + bean1.getName());
form.commit();
System.out.println("After commit: " + bean1.getName());
}
});
mainWindow.addComponent(commitButton);
}
private Container createContainer() {
BeanContainer<Object, Bean> container = new BeanContainer<Object, Bean>(
Bean.class);
container.setBeanIdResolver(new BeanIdResolver<Object, Bean>() {
private static final long serialVersionUID = 1L;
public Object getIdForBean(Bean bean) {
return bean;
}
});
bean1 = new Bean();
container.addBean(bean1);
return container;
}
public class Bean {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
Output after 'beanname' is typed into the table and commit button is clicked:
Form is modified = false
Table is modified = false
Before commit: beanname
After commit: beanname
Any help would be appreciated!
Last updated on Dec, 22nd 2011
You cannot reply to this thread.