NetBeans 6.8 comes with a new wizard, which generates a JSF 2 application from an existing database using EJB 3.1 and JPA 2. The resulting code is even usable for real world projects. Also interesting: the generator templates can be easily edited directly from the wizard. This is a serious killer feature and really usable. You can apply the wizard to a Java EE 6 WAR project and deploy it to Glassfish v3. For this purpose:
- Create a new WAR application and choose Glassfish v3, Java EE 6 and add JSF 2 as a framework.
- Right mouse click on the WAR and choose: "Entity Classes From Database....", choose an existing DataSource, then a Table and don't forget to push the "Create Persistence Unit" button. The result: a JPA entity + persistence.xml.
- Right mouse click on the WAR and choose: "JSF Pages from Entity Classes..." and choose the even generated JPA entity. On the second page you can even customize the templates (just click on the link in the right bottom corner). This is really useful.