Forgive me if I screw up the terminology here.. I'm pretty new to J2EE and Swing development. I'm developing a Swing based application to replace a paper process. It's basically a long form that gets submitted to a server where it is reviewed and in some cases sent back to the user for corrections. I'm having trouble figuring out a good implementation for the data tier.
The prototype that I've developed makes extensive use of the JGoodies framework (Forms, Binding, Validation). The domain model is basically a bunch of POJO's. For each POJO there is a separate validator object which has a a validate() method that returns a ValidationResult object. On the Swing side, there is a Model object for each POJO/Validator which listens for changes to the result of validate(). The GUI class attaches to the model and updates the GUI to reflect results of the validation. Basically the result is that if you don't fill out a required field, the field's background color changes and you get a list of reasons why you aren't allowed to submit the form at the bottom of the page.
Pretty much all of this functionality rests upon the domain model calling 'firePropertyChange' in the setXYZ() functions. This solution seems to work when the client uses Hibernate to persist the objects directly to the DB Server, but I'm wondering if/how it could work if we decided to use EJB3 Entity Beans for storing the data instead of Hibernate (primarily because we don't want to leave our DB server's port open on the firewall).
From what I've gathered, under EJB3 the POJO's that I'm currently using on the client side (which call 'firePropertyChange') would end up on the server (and I am assuming that the 'firePropertyChange' functionality would be broken). When the client binds to the Entity Bean, the server would cause the creation of a new POJO with simple getters and setters based on the interface on the server side. I assume that this code would be generated for me automatically and I wouldn't be able to get the 'firePropertyChange' functionality back. In other words, the binding between the GUI and the POJO would be lost, along with the automatic validation.
Is this still possible? Was it ever? Was it possible with EJB2 using the Home objects? Should I just stick with Hibernate and let the clients access the DB server directly? Does anyone have any idea what I'm talking about? ;)
I'm also developping a Swing application that is using EJB3 and for a part the JGoodies framework (mostly forms and validation, i haven't looked into binding yet, i use two modelToView and viewToModel methods to propagate changes).
The idea of EJB3 is that you can use your entity beans as POJOs out of the container. So you design your objects as POJOs and add extra information on how they should be persisted (very similar to hibernate pojos, only in hibernate you have to use xml files where you can use annotations in an EJB3 pojo). When you need an entity you request it from the server and get a POJO you can work with on the client side. You just edit the object in very similar way you do now and then call a method on the server to propagate the changes to the object to the database (every entity bean is identified by its id). So if you model the EJB3 entity beans with firePropertyChange() you can perfectly use them on the client side. I guess on the server side the firePropertyChange() methods will be ignored as there won't be a listener attached.
I hope i have helped you a bit, i'm certainly not an expert, so if i'm saying stupid thing someone please correct me.
I'm new with EJB3+Swing Apps. And I want if is possible some of your help.
I used to create Swing Apps with NetBeans and I do write lot of code and NetBeans website has some videotutorials that show me how to make a better swing apps with other tecnology (EJB3) but they are not complete, they always make select but not insert into a DB or update.
And now I'm trying JPA + Swing and it seems easy but I still do not know how to Insert and Update with JPA.
Thanks for your help