How to Create a Custom "JSF Pages from JPA Entity Classes" Code Generator

Kay Wrobel is new on the NetBeans Platform developer mailing lists. He's interested in PrimeFaces and really likes NetBeans IDE for that reason (and rightly so, of course). However, being able to modify the templates used to generate JSF pages from entity classes is not enough for him:

Instead, what he'd like is the ability to replace those templates completely, to have multiple PrimeFaces oriented files to be generated, i.e., not following the View/Create/Edit/List approach that you see above, but following his own business requirements.

Currently, there's no API for the above dialog, though that would be nice. So, I've forked the parts of the NetBeans sources that relate to the above dialog (plus some other stuff, since I haven't completely broken it down to its minimum yet) here:

http://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.2/misc/ForkedJSFSupport

You can get the above via Subversion, open in NetBeans IDE 7.2.1, compile it there (several impl dependencies, so you must use 7.2.1), then run it. Then create a new web application create/generate some entity classes, and then you'll be able to go to this new wizard, which comes from the above code:

As you move through the wizard, right now, you'll have exactly the same steps and results as in the standard "JSF Pages from Entity Classes" wizard. The second panel proves that anything can be changed, i.e., notice "Hi Kay!" in the first label below the heading in the main panel in the dialog below:

The result of the above is, currently, exactly as you have in NetBeans IDE: JSF pages created from entity classes. So, now you have the basis for your own PrimeFaces, or whatever, code generator from entity classes.

Those parts of what you add/change to the source code should be contributed back to the NetBeans project, since changes you make are actually changes to the NetBeans source code. Not everything you contribute back will be useful or necessarily accepted, of course, but the point is that in principle anything you add/change is something you should be open to sharing back with the NetBeans project.

Comments:

This looks very interesting.
I have been looking at doing this sort of thing for PrimeFaces myself but never got around to it.
Nice start!

Posted by Andy Bailey on January 16, 2013 at 01:25 AM PST #

Thanks for posting this. It is very nicely done, and gives users a peek into how easy it is to accomplish things in NetBeans.

Posted by John Yeary on January 16, 2013 at 05:52 AM PST #

How are you Geertjan ?
My name is Igor and i'm from Brazil. I modified the templates and it worked really fine, but I need create more classes. I downloaded the source code of netbeans and I would like to modify the wizard generator but I don't find the code of the wizard. could you help me !

Posted by Igor Nunes on April 23, 2013 at 12:07 PM PDT #

http://blog.primefaces.org/?p=2475

They're probably going to be very happy to hear that you'd like to work with them on this.

Posted by Geertjan on April 24, 2013 at 04:10 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today