Hi Everybody,
I’m trying make a Vaadin application with JEE6. I started from that link http://vaadin.com/wiki/-/wiki/Main/Creating%20JEE6%20Vaadin%20Applications (Option 2). Everything works fine. Next I added some views to my application. For example:
public class StudentsManagerView extends VerticalLayout implements AbstractView
{
@Inject
private AccountManagerFacade accountManager;
//fields and methods
}
(AbstractView is just empty interface.)
And inject it to Application:
@SessionScoped
public class MyApp extends Application {
@Inject private StudentManagerView studentManager;
@Override
public void init() {}
}
Evertything works there i have reference to EJB in my view. But, studentManager object is built at application start. Now I have 20 different views which i switch from menu. So i don’t want to build them on startup. So, I used Instance<>.
@Inject private Instance<StudentManagerView> studentManager;
and get instance from studentManager.get().
Yes, works fine now, constructors(init() methods with @PostConstruct annotation to be clear) are called only at first use of view. But, in this place i lost most important think. Always when I want to show view:
splitPanel.setSecondComponent(studentManager.get());
server takes me new instantion of class, so I loose previous state of view.
Injected object(studentManager) should have same scope which “parent” object(myApp) - session scope, but it haven’t when I’m using Instance<>(object is seesion scope with pure @Inject without Instance<>). I tried to use javax.inject.Singleton anntotation with StudentManagerView and it’s work, I have always one instance of object, but it’s shared between all application instances. So, I thought @SessionScoped with StudentManagerView should be that, but there is the problem. I have deploy time exception:
SEVERE: Exception while loading the app : WELD-001437 Normal scoped bean class com.vaadin.ui.AbstractComponent is not proxyable because the type is final or it contains a final method public final java.lang.String com.vaadin.ui.AbstractComponent.getTag().
there in AbstractComponent which I have to use, because Layouts extends it, two final method, which one is depreciated.
Now my question, maybe somebody have some workaround solution for my problem.
Sorry for my bad English, I hope somebody will understand it…
Best Regards,
Artur