vaadin / cdi

CDI Integration for Vaadin
Apache License 2.0
41 stars 56 forks source link

UIScoped, NormalUIScoped or SessionScoped @CDIView does not work as expected #228

Closed tsuoanttila closed 7 years ago

tsuoanttila commented 7 years ago

@bingtimren commented on Mon Nov 20 2017

Environment: Vaadin 8.1.6, Vaadin-CDI 2.0.0, WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) server

Summary of the problem: By definition, UIScoped, NormalUIScoped or SessionScoped beans all should have just one instance per UI or user session. However, when an UIScoped, NormalUIScoped, or SessionScoped @CDIView annotated View was created by CDIViewProvider in navigation, and if that view @Observes certain event, then if such event was fired, it seems that the CDI container does not realise there is already an instance (so as to directly call the observer method of that existing instance). Then, a new instance was initiated, and that new instance received, or "observed" the event. However, the first CDIView, more importantly, the CDIView that was actually shown to the user, did not receive the event.

A full description of the problem is at here

A minimal reproducible example is also attached.

Bing GridLayoutProblemDemo.zip


@tsuoanttila commented on Mon Nov 20 2017

Hi @bingtimren,

can you test if this issue exists in the 3.0.0.alpha1 version of our CDI plugin? There's a number of fixes regarding this topic.


@tsuoanttila commented on Mon Nov 20 2017

Also this seems to be more or less in the wrong repo. https://github.com/vaadin/cdi is the location for CDI related issues.

bingtimren commented 7 years ago

Oh yes, my post was in wrong place. Thanks for moving it here. I'd like to test if this issue exists in 3.0.0.alpha1. However can you point me to a .jar that I can download? I tried to add it through maven dependency but maven cannot find the release. Then I downloaded the source package and try to build it from maven, and maven reports BUILD FAILURE due to failed tests. If you are interested, the surefire reports are here: surefire-reports.zip

tsuoanttila commented 7 years ago

It's available in our Prerelease repository

<repository>
    <id>vaadin-prerelease</id>
    <url>https://maven.vaadin.com/vaadin-prereleases</url>
</repository>
bingtimren commented 7 years ago

Yes, this problem was fixed in 3.0.0.alpha1. I tested a CDIView with SessionScoped and UIScoped, respectively, and it work as expected. As of NormalUIScoped, I found it no longer supported.

Thanks!

tsuoanttila commented 7 years ago

Related to #134

Issue fixed in 3.0.0.alpha1

mrts commented 6 years ago

@tsuoanttila, probably a mistake at my side, but when I enable the pre-releases repository and try to add 3.0.0-alpha1 (or alpha2) as dependency, Maven complains that it cannot find it:

Downloading: http://maven.vaadin.com/vaadin-prereleases/com/vaadin/vaadin-cdi/3.0.0-alpha2/vaadin-cdi-3.0.0-alpha2.pom Downloading: http://maven.vaadin.com/vaadin-addons/com/vaadin/vaadin-cdi/3.0.0-alpha2/vaadin-cdi-3.0.0-alpha2.pom Downloading: https://repo.maven.apache.org/maven2/com/vaadin/vaadin-cdi/3.0.0-alpha2/vaadin-cdi-3.0.0-alpha2.pom [WARNING] The POM for com.vaadin:vaadin-cdi:jar:3.0.0-alpha2 is missing, no dependency information available ... Could not resolve dependencies for project ...: Could not find artifact com.vaadin:vaadin-cdi:jar:3.0.0-alpha2 in vaadin-prereleases (http://maven.vaadin.com/vaadin-prereleases)

Does it still work for you?

tsuoanttila commented 6 years ago

The correct version number is 3.0.0.alpha2. You seem to have a dash instead of a dot. The 3.0.0 final has now been released as well and should be available in maven central.

mrts commented 6 years ago

Ah, indeed, thanks! Great news that 3.0.0 final is released, many thanks for making Vaadin more awesome with every release!