I have a class looking like this:
@Route(value = "dashboard", layout = MainView::class)
@PageTitle("Dashboard")
class DashboardView : VerticalLayout() {
@Autowired
private lateinit var someService: someService
init {
val grids = HorizontalLayout()
grids.justifyContentMode = FlexComponent.JustifyContentMode.CENTER
grids.alignItems = FlexComponent.Alignment.CENTER
// initialize some grids with data from someService
grids.setSizeFull()
add(grids)
setSizeFull()
justifyContentMode = FlexComponent.JustifyContentMode.CENTER
alignItems = FlexComponent.Alignment.CENTER
}
companion object {
const val VIEW_NAME = "Dashboard"
}
}
someService is some class annotated with Spring @Service
annotation which injects someRepository
to access database data.
The problem is that someService cannot be initialized before init block called and seems to be null.
I use Spring version 3.0.2 and Vaadin version 23.
I tried some tricks with @SpringView
or @SpringComponent
annotations, bit still have no idea how to inject this service and make it visible from my UIView init block.