blob: a1182c0dafb9cc842308befeabe0c673803fd3c5 (
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
|
package com.vaadin.tests.push;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.vaadin.data.util.AbstractInMemoryContainer;
import com.vaadin.data.util.BeanContainer;
import com.vaadin.event.ItemClickEvent;
import com.vaadin.event.ItemClickEvent.ItemClickListener;
import com.vaadin.server.ErrorHandler;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinSession;
import com.vaadin.shared.communication.PushMode;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
public class PushErrorHandling extends AbstractTestUI {
@Override
protected void setup(VaadinRequest request) {
getPushConfiguration().setPushMode(PushMode.AUTOMATIC);
VaadinSession.getCurrent().setErrorHandler(new ErrorHandler() {
@Override
public void error(com.vaadin.server.ErrorEvent event) {
addComponent(new Label("An error! "
+ event.getThrowable().getMessage()));
System.err.println("An error! "
+ event.getThrowable().getMessage());
}
});
final Button button = new Button("Click for NPE!",
new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
((String) null).length(); // Null-pointer exception
}
});
button.setId("npeButton");
addComponent(button);
final Table view = new Table("testtable");
view.setId("testtable");
view.setSelectable(true);
view.setMultiSelect(false);
view.setImmediate(true);
view.setSizeFull();
view.addItemClickListener(new ItemClickListener() {
@Override
public void itemClick(ItemClickEvent event) {
BeanContainer<String, AbstractInMemoryContainer> metaContainer = new BeanContainer<String, AbstractInMemoryContainer>(
AbstractInMemoryContainer.class) {
@Override
public Collection<String> getContainerPropertyIds() {
List<String> cpropIds = new ArrayList<String>(super
.getContainerPropertyIds());
cpropIds.add("testid");
return cpropIds;
}
@Override
public Class<?> getType(Object propertyId) {
((Object) null).hashCode();
return super.getType(propertyId);
}
};
view.setContainerDataSource(metaContainer);
}
});
view.addContainerProperty("Column", String.class, "Click for NPE");
view.addItem(new Object());
addComponent(view);
}
@Override
protected String getTestDescription() {
return "Error handling should still work w/ push enabled. (Button can be handled properly, table causes internal error)";
}
@Override
protected Integer getTicketNumber() {
return 11882;
}
}
|