Hengrui Jiang
Hengrui Jiang

Reputation: 881

Vaadin 14: Is it possible to define layout in @Route with a method?

When using @Route, it is possible to define a RouterLayout with the attribute layout. However, I would like to define a global default layout. Is it possible to define the layout in a method, or configure a different default than <body> somehow?

Upvotes: 1

Views: 121

Answers (1)

ollitietavainen
ollitietavainen

Reputation: 4275

You can define a parent layout for any RouterLayout with the @ParentLayout annotation:

@ParentLayout(MyParentLayout.class)
public class MyRouterLayout extends Div implements RouterLayout  {
...

Here MyRouterLayout will be shown inside MyParentLayout, not <body>.

Upvotes: 1

Related Questions