Route / ParentRoute

Hi,

I have a MainLayout with a BackgroundImage and a Banner named HeaderLayout. Now I have a second and a third Layout and I will not include the HeaderLayout again and again. I would work with Route and ParentRoute. But I was not able to do so. Could somebody explain to me, how that could work?

ParentLayout should be the HeaderLayout and all other Layouts should include this.

Thanks Dennis

The HeaderLayout should implement RouterLayout as it’s expected to be in all the layouts.
The other layouts with @Route annotation should be @Route(value = "path", layout = HeaderLayout.class)

This way HeaderLayout will be there for all the other layouts, but to note this means that the other layouts are “added” to the HeaderLayout so anything that HeaderLayout contains will be added before the other contents.

If you want to handle the content inclusion in a special way you can override the showRouterLayoutContent(HasElement content) in HeaderLayout.

Hope this helps.

  • Mikael

Thanks Mikael. I have now the problem, that my HeaderLayout is on left and the other layouts on the right. But I need the header on the top on the other layouts on bottom.

You could change the headerLayout to extend VerticalLayout. That way the added content should always be below the header.

  • Mikael