I’m using Vaadin 7.6.4 and the spring-vaadin-portlet/0.0.5 for VaadinSpringPortlet and @VaadinPortletUI annotations from ru.xpoft.vaadin.
I keep running into situations where init(VaadinRequest request) and @PostConstruct init() essentially conflict with eachother. This is the latest one:-
[code]
public class AbstractUI {
public void init(VaadinRequest request){
request.getService().findVaadinSession(request).setAttribute(“authenticatedUser”,request.getUserPrincipal()));
}
}
public class UI extends AbstractUI {
public void init(VaadinRequest request){
super.init(request);// ensure all my boiler-plate security stuff is init’d
}
@PostConstruct
public void init(){
setContent(myComponentBean);
}
}
public class MyComponentBean {
@Autowired
SomeService someService; // We need this to be instantiated so wait till post-construct to use it.
@PostConstruct
public void init(){
// userSetting needs to be set if not set per-session, provide some UI to do that if not found!
UserSetting userSetting = UI.getCurrent().getSession().getAttribute(“someUserSetting”);
if (user == null){
// load user login UI
}else{
User user = UI.getCurrent().getSession().getAttribute(“authenticatedUser”); /
/NPE here as UI.getCurrent() == null
userSetting = someService.getUserSetttingBasedOnUser(user);
UI.getCurrent().getSession().setAttribute(“someUserSetting”,userSettting);
}
}
[/code]Now I hear you saying already “just reverse it” and have the UI components attached in the init(VaadinRequest) method, but that gives me NPEs when attempting to access my @Autowired properties. I think that is likely the crux of my issue, and I need to investiage that more (some caught exceptions preventing init of lower-order components perhaps).
How is everyone else doing this? I’m avoiding just slamming in spring-boot / custom vaddin portlet / @Configuration based context for now.