blob: aa3c38182b499c3ab174fb6f6f90c23cbe168130 (
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
package com.itmill.toolkit.tests.tickets;
import com.itmill.toolkit.Application;
import com.itmill.toolkit.data.util.BeanItem;
import com.itmill.toolkit.ui.Button;
import com.itmill.toolkit.ui.Form;
import com.itmill.toolkit.ui.FormLayout;
import com.itmill.toolkit.ui.GridLayout;
import com.itmill.toolkit.ui.Label;
import com.itmill.toolkit.ui.Window;
import com.itmill.toolkit.ui.Button.ClickEvent;
public class Ticket2244 extends Application {
Form form;
@Override
public void init() {
Window w = new Window(getClass().getSimpleName());
setMainWindow(w);
GridLayout gl = new GridLayout(3, 3);
gl.setSpacing(true);
gl.addComponent(new Label("Before form"));
gl.newLine();
form = new Form(gl);
form.setItemDataSource(new BeanItem(new MyBean()));
gl.addComponent(new Label("After form"));
w.addComponent(form);
w.addComponent(new Button("new item", new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
form.setItemDataSource(new BeanItem(new MyBean()));
}
}));
w.addComponent(new Button("new bigger item",
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
form
.setItemDataSource(new BeanItem(
new MyBiggerBean()));
}
}));
w.addComponent(new Button("new grid layout",
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
form.setLayout(new GridLayout());
}
}));
w.addComponent(new Button("new form layout",
new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
form.setLayout(new FormLayout());
}
}));
}
public class MyBean {
String firstname;
String lastname;
String password;
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
public class MyBiggerBean extends MyBean {
String address;
String phone;
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
}
|