|
7 | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
8 | 8 | * you may not use this file except in compliance with the License. |
9 | 9 | * You may obtain a copy of the License at |
10 | | - * |
| 10 | + * |
11 | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
12 | | - * |
| 12 | + * |
13 | 13 | * Unless required by applicable law or agreed to in writing, software |
14 | 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
15 | 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
32 | 32 | import com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment; |
33 | 33 | import com.vaadin.flow.component.orderedlayout.HorizontalLayout; |
34 | 34 | import com.vaadin.flow.component.orderedlayout.VerticalLayout; |
| 35 | +import com.vaadin.flow.shared.Registration; |
35 | 36 | import java.io.ByteArrayOutputStream; |
36 | 37 | import java.io.PrintWriter; |
37 | 38 | import java.util.UUID; |
| 39 | +import java.util.stream.Stream; |
38 | 40 | import org.slf4j.Logger; |
39 | 41 | import org.slf4j.LoggerFactory; |
40 | 42 | import org.vaadin.olli.ClipboardHelper; |
@@ -64,6 +66,8 @@ public class ErrorWindow extends Dialog { |
64 | 66 |
|
65 | 67 | private ErrorWindowI18n i18n; |
66 | 68 |
|
| 69 | + private Registration attachListenerRegistration; |
| 70 | + |
67 | 71 | public ErrorWindow(final Throwable cause) { |
68 | 72 | this(cause, null, isProductionMode(), ErrorWindowI18n.createDefault()); |
69 | 73 | } |
@@ -96,7 +100,22 @@ public ErrorWindow( |
96 | 100 | this.errorMessage = errorMessage; |
97 | 101 | this.productionMode = productionMode; |
98 | 102 | this.i18n = i18n; |
99 | | - initWindow(); |
| 103 | + |
| 104 | + attachListenerRegistration = addAttachListener(ev -> { |
| 105 | + attachListenerRegistration = null; |
| 106 | + ev.unregisterListener(); |
| 107 | + initWindow(); |
| 108 | + }); |
| 109 | + } |
| 110 | + |
| 111 | + @Override |
| 112 | + public Stream<Component> getChildren() { |
| 113 | + if (attachListenerRegistration != null) { |
| 114 | + attachListenerRegistration.remove(); |
| 115 | + attachListenerRegistration = null; |
| 116 | + initWindow(); |
| 117 | + } |
| 118 | + return super.getChildren(); |
100 | 119 | } |
101 | 120 |
|
102 | 121 | public ErrorWindow(ErrorDetails errorDetails) { |
|
0 commit comments