How to create multiple instances of Vaadin Spring bean?

I am playing around with vaadin spring in a boot container - it looks great guys. However I cannot manage to do one simple thing. I will make the problem simple - I have a cycle that creates Buttons in a table. If user clicks on one of these buttons, he gets a modal Window.

for (...) {
   layout.add(new DetailButton());
}

But I need that this DetailButton is spring managed! I can define the Scope(“prototype”) and inject it but however, but it will be the same instance:

@Inject
private DetailButton detailButton

for (...) { layout.add(detailButton); } So this obviously si no-go. So how can I create multiple instances of this vaadin spring bean so that is still spring managed? Thank you

This is more of a Spring related question, but you can get fresh instances of beans through the ApplicationContext’s getBean method. However, I recommend reading
this post about why it might be a bad idea
.

Yeah, getBean method SHOULD be the last option. It is as bad as to assign applicationContext to static property :slight_smile: