@@ -53,8 +53,10 @@ public abstract class BeforeEvent extends EventObject {
5353 private NavigationState rerouteTargetState ;
5454 private ErrorParameter <?> errorParameter ;
5555
56- private String forwardToUrl = null ;
57- private String rerouteToUrl = null ;
56+ private String unknownForward = null ;
57+ private String unknownReroute = null ;
58+
59+ private String externalForwardUrl = null ;
5860
5961 /**
6062 * Constructs event from a NavigationEvent.
@@ -165,7 +167,7 @@ public BeforeEvent(Router router, NavigationTrigger trigger,
165167 * @return forward route is not found in the route registry.
166168 */
167169 public boolean hasUnknownForward () {
168- return forwardToUrl != null ;
170+ return unknownForward != null ;
169171 }
170172
171173 /**
@@ -175,7 +177,7 @@ public boolean hasUnknownForward() {
175177 * @return reroute is not found in the route registry.
176178 */
177179 public boolean hasUnknownReroute () {
178- return rerouteToUrl != null ;
180+ return unknownReroute != null ;
179181 }
180182
181183 /**
@@ -184,7 +186,7 @@ public boolean hasUnknownReroute() {
184186 * @return the unknown forward.
185187 */
186188 public String getUnknownForward () {
187- return forwardToUrl ;
189+ return unknownForward ;
188190 }
189191
190192 /**
@@ -193,7 +195,16 @@ public String getUnknownForward() {
193195 * @return the unknown reroute.
194196 */
195197 public String getUnknownReroute () {
196- return rerouteToUrl ;
198+ return unknownReroute ;
199+ }
200+
201+ /**
202+ * Gets the external forward url.
203+ *
204+ * @return the external forward url or {@code null} if none has been set
205+ */
206+ public String getExternalForwardUrl () {
207+ return externalForwardUrl ;
197208 }
198209
199210 /**
@@ -229,6 +240,15 @@ public boolean hasForwardTarget() {
229240 return forwardTarget != null ;
230241 }
231242
243+ /**
244+ * Check if we have a forward for an external URL.
245+ *
246+ * @return forward target exists
247+ */
248+ public boolean hasExternalForwardUrl () {
249+ return externalForwardUrl != null ;
250+ }
251+
232252 /**
233253 * Check if we have a reroute target.
234254 *
@@ -361,10 +381,22 @@ public void forwardTo(String location) {
361381 location ));
362382 } else {
363383 // Inform that forward target location is not known.
364- forwardToUrl = PathUtil .trimPath (location );
384+ unknownForward = PathUtil .trimPath (location );
365385 }
366386 }
367387
388+ /**
389+ * Forward to the given URL instead of the component about to be displayed.
390+ * <p>
391+ * This function performs a page reload in the browser with the new URL.
392+ *
393+ * @param externalForwardUrl
394+ * forward target location string
395+ */
396+ public void forwardToUrl (String externalForwardUrl ) {
397+ this .externalForwardUrl = externalForwardUrl ;
398+ }
399+
368400 /**
369401 * Forward to navigation component registered for given location string with
370402 * given location parameter instead of the component about to be displayed.
@@ -505,7 +537,7 @@ public void rerouteTo(String route) {
505537 route ));
506538 } else {
507539 // Inform that reroute target location is not known.
508- rerouteToUrl = PathUtil .trimPath (route );
540+ unknownReroute = PathUtil .trimPath (route );
509541 }
510542 }
511543
0 commit comments