diff --git a/flow-server/src/main/java/com/vaadin/flow/router/AbstractRouteNotFoundError.java b/flow-server/src/main/java/com/vaadin/flow/router/AbstractRouteNotFoundError.java index 037b2896c9e..b9b2b253701 100644 --- a/flow-server/src/main/java/com/vaadin/flow/router/AbstractRouteNotFoundError.java +++ b/flow-server/src/main/java/com/vaadin/flow/router/AbstractRouteNotFoundError.java @@ -78,9 +78,10 @@ public int setRouteNotFoundErrorParameter(BeforeEnterEvent event, String template; String routes = getRoutes(event); + boolean noRoutes = routes.isEmpty(); if (productionMode) { template = AbstractRouteNotFoundError.LazyInit.PRODUCTION_MODE_TEMPLATE; - } else if (routes.isEmpty()) { + } else if (noRoutes) { // Offer a way for people to get started template = readHtmlFile("NoRoutesError_dev.html"); } else { @@ -97,6 +98,18 @@ public int setRouteNotFoundErrorParameter(BeforeEnterEvent event, template = template.replace("{{path}}", path); getElement().setChild(0, new Html(template).getElement()); + if (noRoutes && !productionMode) { + String copilotNoRoutes = """ + (function poll() { + if (window.Vaadin?.copilot?.noRoutesInProject) { + window.Vaadin.copilot.noRoutesInProject(); + } else { + setTimeout(poll, 100); + } + })(); + """; + getElement().executeJs(copilotNoRoutes); + } return HttpStatusCode.NOT_FOUND.getCode(); } diff --git a/flow-server/src/main/resources/com/vaadin/flow/router/NoRoutesError_dev.html b/flow-server/src/main/resources/com/vaadin/flow/router/NoRoutesError_dev.html index 3032781a8f8..1af708d50c1 100644 --- a/flow-server/src/main/resources/com/vaadin/flow/router/NoRoutesError_dev.html +++ b/flow-server/src/main/resources/com/vaadin/flow/router/NoRoutesError_dev.html @@ -1,13 +1,9 @@
To get started, you can either
+To get started, you can
- You can also create a view manually in your IDE, see the tutorial -
-Learn more at https://vaadin.com/docs.