Spring Boot - Vaadin 8 -> Navigation Issue

Hi,

I’ve recently initialized a project from “https://start.spring.io/” with vaadin, jpa etc for a simple application with spring-boot. I wanted to leverage the JPA facilities Spring-Boot offers.

  • Task 1: Navigate to LoginView, get UserRepository up and running…
  • Task 2: Navigate to LoginView, navigate to ErrorView click back…

Annotations and indicative implementation on UI Class

@SpringUI(path = "/app")
@SpringViewDisplay
@Push
public class MainUI extends UI {

...
    @Autowired
    private SpringNavigator nav;

...
	@Override
    protected void init(VaadinRequest request) {
		nav.navigateTo((LoginView.NAME) + "/param");
	}

And The LoginView Class →

@UIScope
@SpringView(name = "Login")
public class LoginView extends VerticalView {

    public static final String NAME = "Login";
	private MTextField txtUserName;
    private PasswordField txtPassword;
    private MLabel lblLogin;
    private MButton btnLogin;
...

    @Autowired
    UserRepository userRepo;

For Task 1 the above implementation is working ok, as expected… Autowiring and management is done by the container correctly and the repository is instantiated correctly.

For Task 2, the results are a bit off.
The behaviour of SpringNavigator is similar to adding references of views to navigator like the code below. Although no such thing exists.

Navigator nav = new Navigator(this,this);
nav.addView(NAME,new LoginView());

So each time we get back from another view ( i.e. ErrorView ), the components are duplicated and added in the Layout, as shown in the attached picture. As if the instance of the object wasn’t destroyed and for the same instance, the enter method was called again.
Adding removeAllComponents() is not a good option for the task as well as, it seems that the management of the view’s lifecycle would be a done manualy.

The behaviour for Task 2 is “fixed” upon removing the @SpringView(name = “/Login”) annotation, which in turn results in failure of Task 1 as the
UserRepository autowiring failes ( NullPointerException ).

Any thoughts on how to get the “proper” behaviour set using Spring’s Navigator?

Thanks in advance,
Nikolas

17457020.png