I'd like to create the following simple MVP architecture:
View classes that are simly the vaadin layout, components, styles. nonfunctional. The views should be tied to the current ViewScope/SessionScope, therefore I use
@UIScope
of https://github.com/peholmst/vaadin4springPresenters should have the view injected, register listeners on the view components, handle user input and delegate to the model services
Problem: when I inject the view into the presenter, the view is recreated, thus presenter and view are not in the same scope. So the binding will not work. What can I change to achieve the design described above?
@VaadinComponent
@UIScope
public class LoginView {
//form fields, buttons
}
@Controller
public class LoginPresenter implements ClickListener {
@Autowired
private LoginView view;
@PostConstruct
public void bind() {
view.getLoginButton().addClickListener(this);
}
@Override
public void buttonClick(ClickEvent event) {
//validate input and login
}
}