01: package wingset;
02:
03: import org.wings.*;
04: import org.wings.event.SRequestListener;
05: import org.wings.event.SRequestEvent;
06:
07: import java.awt.event.ActionListener;
08: import java.awt.event.ActionEvent;
09:
10: public class ErrorPageExample extends WingSetPane {
11:
12: protected SComponent createControls() {
13: return null;
14: }
15:
16: protected SComponent createExample() {
17: SButton incremental = new SButton(
18: "Error during incremental request");
19: incremental.addActionListener(new ActionListener() {
20: public void actionPerformed(ActionEvent e) {
21: throw new RuntimeException("Show error page!");
22: }
23: });
24: SButton complete = new SButton("Error during complete request");
25: complete.addActionListener(new ActionListener() {
26: public void actionPerformed(ActionEvent e) {
27: getParentFrame().reload();
28: getSession().addRequestListener(new SRequestListener() {
29: int count = 0;
30:
31: public void processRequest(SRequestEvent e) {
32: if (e.getType() == SRequestEvent.PROCESS_REQUEST) {
33: if (count == 0)
34: // omit the current request
35: count++;
36: else {
37: // this is the reload
38: getSession()
39: .removeRequestListener(this );
40: throw new RuntimeException(
41: "Show error page!");
42: }
43: }
44: }
45: });
46: }
47: });
48:
49: SPanel panel = new SPanel(new SGridLayout(1, 2, 10, 10));
50: panel.addComponent(incremental);
51: panel.addComponent(complete);
52:
53: return panel;
54: }
55: }
|