I’m attempting to have my custom RouteNotFoundError redirect back to the “home” view.
When the redirect happens I can see the URL briefly change to “home” but then it goes back to whatever garbage i put in…Can someone please tell me whats wrong here?
@ParentLayout(MainLayout.class)
@PageTitle(IdeaConst.TITLE_NOT_FOUND)
@JsModule("./styles/shared-styles.js")
public class CustomRouteNotFoundError extends RouteNotFoundError {
public CustomRouteNotFoundError() {
System.out.println("Route not found.");
}
@Override
public int setErrorParameter(BeforeEnterEvent event, ErrorParameter<NotFoundException> parameter) {
event.forwardTo("home");
return HttpServletResponse.SC_NOT_FOUND;
}
}
@PageTitle("Welcome")
@Route(value = "home", layout = MainLayout.class)
@RouteAlias(value = IdeaConst.PAGE_ROOT, layout = MainLayout.class)
public class Home extends ViewFrame {
public Home() {
setId("home");
setViewContent(createContent());
}
private Component createContent() {
FlexBoxLayout content = new FlexBoxLayout();
content.setAlignItems(FlexComponent.Alignment.CENTER);
content.setFlexDirection(FlexDirection.COLUMN);
return content;
}
}