kumm / flow-cdi-addon

3 stars 1 forks source link

Documentation could use a couple of "how to" #10

Open chrisowensboston opened 6 years ago

chrisowensboston commented 6 years ago

As a Vaadin noob, I could use either a concise instruction or a snippet of example code. I am very familiar with CDI and related concepts but I know nothing about the Vaadin scopes.

For example, how would I modify the MainView class in the Vaadin Flow Tutorial to allow @Inject to work?

Also, I have a bunch of ejb @Stateless beans that are part of an imported module that is not Vaadin aware. How would I make them available for injection in a Vaadin view?

The use case, I imagine, is pretty common: consider a DAO or any back-end service that is implemented as an EJB but is not Vaadin-aware; I'd like my GUI components to be able to get hold of an instance or proxy by injection.

kumm commented 6 years ago

For using @Inject you have nothing to do. As you can see in readme: "Introduce addon as a dependency, and start using @Inject in your route targets, or layouts."

Nothing special. Since MainView from the tutorial is a route target, just @Inject. Of course you should replace constructor with a @PostConstruct method to be able to use your injected beans there.

And don't forget to deploy on a jee7 container. You see jetty in vaadin demos, it won't work. Currently TomEE, Wildfly, and Payara are tested, but should work on any compliant jee7 container.

I am going to look for a proper way to publish some demo app, or apps.

chrisowensboston commented 6 years ago

Thank you for your prompt response. I am using TomEE as a container. I have a method with the annotation @PostConstruct, which it appears is never invoked.

kumm commented 6 years ago

Can you share more info with me? pom.xml, web.xml, beans.xml, and the Route target. If it's open, sharing your full project would be the best.

chrisowensboston commented 6 years ago

Project is not public but I will create a minimal project that exhibits this problem, and will share it. Probably will take a day or two.

From: kumm notifications@github.com Sent: 05/11/2018 2:42 AM To: kumm/flow-cdi-addon flow-cdi-addon@noreply.github.com Cc: chrisowensboston ctag@chris-owens.com; Author author@noreply.github.com Subject: Re: [kumm/flow-cdi-addon] Documentation could use a couple of "how to" (#10)

Can you share more info with me? pom.xml, web.xml, beans.xml, and the Route target. If it's open, sharing your full project would be the best.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kumm/flow-cdi-addon/issues/10#issuecomment-388275675 , or mute the thread https://github.com/notifications/unsubscribe-auth/AQKb5-v01L9mXj9Ex26wYgsWitxe6EKWks5txTLMgaJpZM4T6IHP . https://github.com/notifications/beacon/AQKb51BxXTVPSDKhVYBu8I_UBpkGqSOcks5txTLMgaJpZM4T6IHP.gif

kumm commented 6 years ago

Thanks, a runnable project is always the best. But don't forget about logs. TomEE and application startup logs may help.