flow router

Can someone share how to know the current route I need to identify this in the Main view which is a parent layout for a few child layouts. Thanks.

One option is to have your layout implement BeforeEnterObserver. The event argument passed to the callback contains the current route.

	@Override
	public void beforeEnter(BeforeEnterEvent event) {
		String path = event.getLocation().getPath();
		...
	}

Thanks Jack. One more thing related to the route, I am using vaadin 12, I see the page state is not preserved when I navigate through the routes it looks the page refreshes each time it is called. Any clues on this? Appreciate your help. thanks.

Are you asking about how to make a view UIScoped (e.g. user goes to index1, then index2, then index1. Index1 should be same instance)? If so, then no, I haven’t had a need for that yet.

But maybe this helps. In my application, I have the parent layout add any common UI components to the web page. In the below example, Layout1 adds the application’s header and navigation tabs. Layout2 has additional UI customizations. Since IndexView1 and IndexView2 both specify a parent layout that includes Layout1, they share the same instance of UI components for header and navigation tabs.

public class Layout1 extends StandardLayoutBase

@ParentLayout(Layout1.class)
public class Layout2 extends Div implements RouterLayout

...

@Route(value = "index", layout = Layout1.class)
public class IndexView1 extends HorizontalLayout

@Route(value = "index2", layout = Layout2.class)
public class IndexView2 extends HorizontalLayout

User state is stored in a spring bean scoped as UIScope. The page state is autowired to the view via its constructor.

	@Autowired
	public HomeView(SiteService siteService, UIState uiState)

I am doing this same but looks my UI state is not preserved, the 2 Index views refresh each time they are reopened.

I also facing same problem, i want to set my router path but when i tried to do it shows an error [windows defender error 577]
(https://www.fixerrorcodes.net/blog/resolve-windows-defender-error-577/),i really have no idea why it happened so i want a proper solution how to remove this error.