springvaadin7vaadin-touchkitvaadin4spring

Vaadin4spring and Vaadin Touchkit NavigationView


I'm trying to inject a couple of spring services into a NavigationView (Vaadin Touchkit) and the view is not being managed by Spring at all, so no @PostConstruct method is called and therefore services are not being called.

Is it possible to manage this type of views as spring beans the same way normal Vaadin Views can be managed?

Otherwise, how can I use a injected service in a Vaadin Touchkit NavigationView?

Declaration of the class:

@VaadinView(name = Views.HOME)
@UIScope
public class HomeView extends NavigationView {
    @Autowired
    private WindDataClientService windDataClientService;
    @Autowired
    private ForecastDataService forecastDataService;
    ...
    ...
    ...
    @PostConstruct
    public void init() {
        grpConditions.addComponent(lnkConditionsTitle);
        grpConditions.addComponent(buildConditionRows());
        lblAlertsTitle.setCaption(lblAlertsTitle.getCaption() + forecastDataService.findClosestForecast());
    }
}

Thanks a lot in advance


Solution

  • You should consider TouchKits NavigationView just as a normal Vaadin component, like VerticalLayout or Panel, not as a Vaadin Navigator View. So no need to annotate it with @VaadinView, but just with Component (~@VaadinComponent).

    If you want to use NavigationView components with Navigator, you'd need some other tricks. You'd at least need to make your view implement the View interface related to the Navigator. I haven't tried that, but I think it should work as well.