CDI MVP add-on

Hi Tomi,

is there a way to use “@XXProperties qualifiers” with subclasses of the vaadin components?

Can I do something like:
@Inject @TextFieldProperties(captionKey = “someKey”)
protected MyTextField someString;

If that does not work: where can I find the source code of org.vaadin.addon.cdiproperties.producer.ComponentProducers?

Thanks a lot in advance,
Jürgen

Hello Jürgen
You may use the TextFieldProperties annotations with subclasses as well but then you’ll need to specify the “implementation” -property.
Also, the field must be of type TextField

@TextFieldProperties(captionKey = “someKey”, implementation = MyTextField.class)
protected TextField someString;

Tomi

Great, thank you! That was what I was looking for!

By the way: I couldn’t find the code for org.vaadin.addon.cdiproperties.producer.ComponentProducers on github. Is it available somewhere else?

Thanks again,
Jürgen

ComponentProducers is a generated java file so it’s not committed to the repository.

Hi Tomi,

while I got the “implementation”-property working, it seems that Injection into implementation classes does not work (also: @PostConstruct is not executed).

Are those implementation instances created with “new”? Is there a way to use CDI with implementation classes?

Thank you,
Jürgen

That’s correct. It won’t work as a cdi-bean as it’s instantiated with reflection.

Hi,
it seams to me, that the CDI-MVP package is broken, since Vaadin CDI 1.0.0.beta4.
On @UIscoped CDIVIEWs the presenter get’s a different View injectet than the one that is used for the user interaction.
I also tried to update to the version from git that should work with 1.0.0.beta4 but in this package the navigation test fails with the same issue.

Any hints how to get this working again ?

Stefan

Have the same problem. I’m not sure if that is a problem caused by the add on. there is a
ticket
for this issue. Anyhow is there a quick workaround available ?

Yeah it’s a Vaadin CDI problem and unfortunately the issue still remains :frowning: I tried tweaking CDIViewProvider a bit so that the referred test passes but can’t really tell if it’s correct otherwise. Added it as an attachment.
18506.java (12 KB)

Good addon!
I suppose you would make new release to compatibilize with new ones of vaadin-cdi when the referred issue went live, wouldn’t you?
So, by right now, can you recommend which version of vaadin-cdi we should use with your last release?

I am obtaining this error when starting AS, due to compatibility with vaadin-cdi lates’t version:

Caused by: org.jboss.weld.exceptions.DefinitionException: WELD-000040: All stereotypes must specify the same scope OR a scope must be specified on Merged stereotype model; Any of the stereotypes is an alternative: false; possible scopes [@com.vaadin.cdi.UIScoped(), @com.vaadin.cdi.ViewScoped()]

The problem is that I have some classes maked with @CDIView annotation (which in lastest versions is @Stereotype @ViewScoped); and the AbstractMVPView included in the addon is @UIScopedStereotype (@Stereotype @UIScoped).
This causes the conflict above.

How about this 2 alternatives
1 creating a new @ViewScopedStereotype to syncrhonize with @CDIView and mark this AbstractMVPView?
2 removing stereotype from AbstractMVPView?

Or Are there any other suggestions to avoid this conflict?