The module is being release as an installable NBM plugin module. The module is NetBeans implementation dependent, so please watch for the implementation version indicated in the file. If the IDE you're using is not the same, please go ahead and try [Installing Into Another NetBeans Version].
PrimeFaces CRUD Generator.
Important: If you are using a newer version of NetBeans (7.3.1+) that ships with Glassfish 4.0 and JSF 2.2, please be sure to download and add the latest PrimeFaces library from the PrimeFaces Download page. As of this writing, PrimeFaces offers version 4.0 under the Community Downloads section. Add the library to your NetBeans installation under Tools -> Ant Libraries and call it "PrimeFaces 4.0". This will make PrimeFaces 4.0 available to the "Web Applciation" wizard.
/faces/*and select Facelets as Preferred Page Language.
Note: If you created a CDI project by adding a
beans.xml file to it, be sure to visit the [Context Dependency Injection And Its Impact On The Generator] Wiki page which highlights some of the code differences.
You have two choices for doing this: you can either program your own entities and persistence unit, or you can let NetBeans generate entities from an existing database. For this sample application, the latter is being used.
jdbc/samplefrom the list. NetBeans connects to the server-supplied Derby
SAMPLEdatabase and populates Available Tables.
NetBeans generates the entities package and seven entity classes:
It also added a
persistence.xml file to the project for referencing the sample database.
Note: The code generator can now detect PrimeFaces version and Apache MyFaces CODI CDI-Extension version!
@ViewAccessScopedannotations. Recent versions of JSF starting with 2.2 have native support for CDI
NetBeans will now generate multiple files under source packages and under Web Pages. Here is a break-down of what was created:
css/pfcrud.cssCascading Style Sheet
<p:menuitem>tags for each entity
template.xhtmlcontaining one PrimeFaces
<p:layoutUnit>tags, four for each side, and one for the middle, where the body will be inserted for each page. The
position="north"also has the
appmenu.xhtmlfile included so that the menu bar will show on top.
index.xhtmlwith a welcome message
List.xhtmlwhich are include files containing
<ui:composition>tags, and the publicly exposed
index.xhtmlwhich wraps these files together to one page to be shown to the end-user, containing
<p:dialog>tag an HTML form, and various other PrimeFaces equivalents of JSF tags, such:
View.xhtmlrepresenting a simple view of the data
<p:ajax>** tags for catching rowSelect and rowUnselect AJAX events to update the View and Edit buttons, which will be disabled when no row is selected and enabled when a row is selected.
controllerspackage contains Facade files known from NetBeans' own "JSF Pages from Entity Classes" wizard, with one
AbstractFacade.javaclass encapsulating JPA operations for all kinds of entities, and one
EntityFacade.javafor each entity
beanspackage has a structure similar to the Facade pattern, with one
AbstractController.javaclass encapsulating all common JSF operations and then
EntityController.javaclasses for each entity. Since this project does not use Container-managed Dependency Injection, each entity bean is annotated with
@ViewScoped. Having every bean inside a Session is not recommended.
converterspackage contains one converter class per entity.
@FacesConverterclasses used to be static and embedded inside the
EntityControllerclasses. After identifying problems when many-to-many relationships were used and
<p:selectManyMenu>is generated, a design change was implemented to give Converters their own package and class.
itemLabelattributes in drop-down lists as well as for the
List.xhtmlfiles. If it was unable to identify such fields, the entity's
@Idfield was used. This is thanks to the Field name artifacts feature introduced in recent versions of the generator. If an entity field contains either
name(in that order), that field is then being used for e.g. the manufacturer name or the product code. This will greatly increase developer productivity as this allows developers to provide their own commonly used field names according to their data model!
If you followed all the steps exactly as described above, you should now be able to Run the application inside GlassFish. Click on the Run button and observe the new pages. You can find some screen shots here:
None at the time of this writing. Be sure to check the Tickets area for any open issues.