Reputation: 1642
I'm using Vaadin 12.0.3 and I'm trying to create a top menu bar using an AppLayout
. Therefore I added the AppLayout
, which contains the Menu to my main view - the DashboardView
(which extends RouterLayout
). This view should be the parent view for the MonitoringView
which displays some data. Therefore I'm setting the @Route
annotation to the MonitoringView
like this: @Route(Monitoring.route, layout = DashboardView::class)
.
The problem is if I add layout = DashboardView::class
to the annotation all styling of the MonitoringView
is gone. This means texts are not displayed, (background-)colors and shadows are gone and so one. When I remove the layout part from the annotation everything looks fine but then I can't see the menu bar on top.
Here's the code for the mentioned classes:
The DashboardView
, which should be the parent for the other view and contains the menu (AppLayout
):
@UIScope
@SpringComponent
@Route("dashboard")
@PageTitle("Dashboard")
class DashboardView() : VerticalLayout(), BeforeEnterObserver, RouterLayout {
init {
val appLayout = AppLayout()
val menu = appLayout.createMenu()
menu.addMenuItems(
AppLayoutMenuItem("Page 1", "monitoring"),
AppLayoutMenuItem("Page 2")
)
add(appLayout)
}
}
The MonitoringView
that shows monitoring data and should be displayed below the menu bar when the user clicks on "Page 1":
@UIScope
@SpringComponent
@Route("monitoring", layout = DashboardView::class)
class MonitoringView() : VerticalLayout(), BeforeEnterObserver {
...
}
Upvotes: 1
Views: 387
Reputation: 12305
Maybe the @Route
property layout
needs the java class instead of the Kotlin class?
Try layout = DashboardView::class.java
.
See https://kotlinlang.org/docs/reference/reflection.html
Note that a Kotlin class reference is not the same as a Java class reference. To obtain a Java class reference, use the .java property on a KClass instance.
Upvotes: 0