blob: d100f61e307a123f1d3eddc3b8c3f06081707bc7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
package com.vaadin.tests.tickets;
import com.vaadin.data.Item;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.data.util.IndexedContainer;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.server.LegacyApplication;
import com.vaadin.ui.AbstractOrderedLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.LegacyWindow;
import com.vaadin.ui.Table;
public class Ticket2242 extends LegacyApplication implements
ValueChangeListener {
private Object tableValue = null;
private Table t;
private String valueDataSource = "-";
private ObjectProperty<String> prop;
@Override
public void init() {
LegacyWindow w = new LegacyWindow(getClass().getSimpleName());
setMainWindow(w);
// setTheme("tests-tickets");
createUI((AbstractOrderedLayout) w.getContent());
}
private void createUI(AbstractOrderedLayout layout) {
Button b = new Button("Change container datasource",
new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
for (int i = 0; i < 5; i++) {
t.setContainerDataSource(createContainer());
// prop.setValue("ipsum");
}
}
});
layout.addComponent(b);
t = new Table("A table");
prop = new ObjectProperty<String>(valueDataSource);
t.setPropertyDataSource(prop);
t.setSelectable(true);
t.setImmediate(true);
t.setPageLength(5);
t.setContainerDataSource(createContainer());
tableValue = t.getValue();
t.addListener(this);
layout.addComponent(t);
}
private IndexedContainer createContainer() {
IndexedContainer ic = new IndexedContainer();
ic.addContainerProperty("a", String.class, null);
for (String s : new String[] { "Lorem", "ipsum", "dolor", "sit",
"amet", "consectetuer" }) {
Item item = ic.addItem(s);
item.getItemProperty("a").setValue(s);
}
return ic;
}
@Override
public void valueChange(ValueChangeEvent event) {
System.out.println("Value change from " + tableValue + " to "
+ t.getValue());
tableValue = t.getValue();
}
}
|