我们使用vaadin-cdi(14.0.0)使用vaadin 23(23.0.9),并且在@RoutEscoped组件中的有条件观察者有问题(如教程中所述):
@RouteScoped
public class ScopedComponent extends Div {
private void onMessage(
@Observes(notifyObserver = IF_EXISTS)
MessageEvent message) {
setText(message.getText());
}
}
我们在tomcat 9上运行并使用Weld( 3.1.9.dinal)作为我们的CDI实施。
我们当前的问题是,在触发@Routescoped组件中观察到的事件时,我们会得到以下例外:
java.lang.illegalstateException:路由所有者'类XXX'实例在活动导航组件链中不可用:不存在bean'yyy'定义的范围。
我们认为问题是Vaadin CDI 13.0.0中实施的更改():
不允许在没有活动路由组件时尝试使用@RoutesCope。
在我们正在使用的焊缝实现中,方法getReceiverifexists在类routescopedContext中调用方法getContextualStorage()。在考虑观察者的接受之前,称为getReceiverifexists。因此,所有在事件上都有观察者的类都试图接收,并且由于并非所有@Routescoped类都在当前的导航链中,因此上述错误被丢弃。
Object receiver = getReceiverIfExists(null); //this is where the exception is thrown
if (receiver == null && reception != Reception.IF_EXISTS) {
// creational context is created only if we need it for obtaining receiver
// ObserverInvocationStrategy takes care of creating CC for parameters, if needed
creationalContext = beanManager.createCreationalContext(declaringBean);
receiver = getReceiverIfExists(creationalContext);
}
if (receiver != null) {
sendEvent(event, receiver, creationalContext);
}
我们不太确定,我们做错了什么或可以做些什么。我们是否使用正确的版本Vaadin-CDI和Weld?
We are using Vaadin 23 (23.0.9) with vaadin-cdi (14.0.0) and are having problems with conditional observers in @RouteScoped components (like it is described in the tutorial):
@RouteScoped
public class ScopedComponent extends Div {
private void onMessage(
@Observes(notifyObserver = IF_EXISTS)
MessageEvent message) {
setText(message.getText());
}
}
We are running on Tomcat 9 and use Weld (3.1.9.Final) as our CDI implementation.
Our current problem is that we get the following exception when firing an event that is observed in a @RouteScoped component:
java.lang.IllegalStateException: Route owner 'class XXX' instance is not available in the active navigation components chain: the scope defined by the bean 'YYY' doesn't exist.
We believe that the problem are the changes implemented in Vaadin CDI 13.0.0 (https://github.com/vaadin/cdi/releases/tag/13.0.0):
Trying to use @RouteScope when there is no active route component present is not allowed.
In the Weld implementation we are using, the method getReceiverIfExists calls the method getContextualStorage() in class RouteScopedContext. And getReceiverIfExists is called before the reception of the observer is considered. Therefore all classes that have an observer on the event are trying to be received and since not all @RouteScoped classes are in the current navigation chain, the above mentioned error is thrown.
Object receiver = getReceiverIfExists(null); //this is where the exception is thrown
if (receiver == null && reception != Reception.IF_EXISTS) {
// creational context is created only if we need it for obtaining receiver
// ObserverInvocationStrategy takes care of creating CC for parameters, if needed
creationalContext = beanManager.createCreationalContext(declaringBean);
receiver = getReceiverIfExists(creationalContext);
}
if (receiver != null) {
sendEvent(event, receiver, creationalContext);
}
We are not quite sure, what we are doing wrong or what we could do differently. Are we using the correct versions vaadin-cdi and Weld?
发布评论
评论(1)
这是Vaadin-CDI(版本14.0.0)中的一个错误: https:https:// github。 com/vaadin/cdi/essess/390
已经合并了一个错误:
This is currently a bug in vaadin-cdi (version 14.0.0): https://github.com/vaadin/cdi/issues/390
A bugfix is already merged: https://github.com/vaadin/cdi/pull/393