Project

General

Profile

JWt with CDI and JPA

Added by David Hubbard almost 10 years ago

Has anyone done any integration of JWt with Java Persistence API (JPA) or more generally with Contexts and Dependency Injection (CDI)?

I'm looking to see how a JWt app could be built using these - on the assumption that there will be no Java port of the Witty C database ORM (Wt::Dbo).

Cheers

Dave


Replies (2)

RE: JWt with CDI and JPA - Added by Pieter Libin almost 10 years ago

Hi David,

You can use a JWt application together with CDI similarly to how you would use a Swing application with CDI.

JWt provides also other mechanisms to manage dependencies:

- MVC: by providing several models and view widgets to work with these models, more information and some example can be found in the MVC section of the gallery example (http://jwt.emweb.be/jwt-gallery/gallery)

  • signal/listeners: demonstrated by ShapesCaptchaWidget#completed() in the planner example

There are indeed no plans to port Dbo to Jwt, since there are several popular JPA implementations available in the Java ecosystem already.

The planner example demonstrates on how to use JWt in combination with JPA, which is very similar to using JPA with a desktop application. Make sure to have a look at WApplication#notify(), this method allows you to free resources used during request handling, when working with JPA you should make sure to handle any database errors here and to rollback your JPA session when it is active (as demonstrated in PlannerApplication#notify()).

Kind regards,

Pieter

RE: JWt with CDI and JPA - Added by David Hubbard almost 10 years ago

Pieter

Thanks for the steer, I'll look into those examples.

At the moment I am also investigating Seam Persistence (for transaction management using JPA outside stateless EJB containers) and trying to work out how it could integrate with JWt. I'm facing some problems there, but hoping to extend your TreeDragDrop example using this approach. I can feed back on this if/when I get closer.

Regards

Dave

    (1-2/2)