0

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

frandevel
  • 747
  • 7
  • 22

1 Answers1

1

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.

mstahv
  • 1,784
  • 9
  • 7
  • Thanks a lot Matti. I will try with the first option as it looks more natural. Maybe I missed something but, does this mean that you can already proxy (spring) any Vaadin component only by using this annotation? To, for instance, inject a custom component into a view not needing to instantiate it? To good to be true? ;O) – frandevel Nov 17 '14 at 15:44
  • Good point. I did not realize that it was extending AbstractComponentContainer – frandevel Nov 17 '14 at 15:48