Next Step: Generate Simple JSF Application

My last blog entry shows a wizard that generates Java Persistence API entity classes from database tables. What was your first question after you tried that wizard? I guess you asked: "OK, what do I do with these classes now? Can I run the application and see them?" I will show you how you can - after you run one more wizard.

The wizard generates a very simple JSF application the follows the CRUD pattern. It lets the user Create, Retrieve (view), Update and Delete data. The generated code includes a JSF managed bean, three JSF pages and some navigation rules in faces-config.xml. The managed bean takes care of access to EntityManager, retrieves and persists entities and also directs navigation between pages. The three JSF pages are: List.jsp, New.jsp and Edit.jsp.

The wizard is launched from File | New File.., select category Persistence and there is JSF Pages from Entity Class. Click next and just select the entity class:

When you finish the wizard you can run the application. Point the browser to a URL of the List page (e.g. http://localhost:8080/GenerateJsf/faces/discountCode/List.jsp) and you will see something like this:

And when you click "New DiscountCode" you will get:

The Edit page is similar...

You can use this for quick testing of your entity classes or as a starting point for your own development. You can also treat it as a simple sample application that shows the whole path from DB to browser. The generated code is very brief and very readable.

To set your expectations correctly, I am writing this only a couple days after I implemented the first version :-). The current version does not support relationships between entity classes, so if your entity classes have relationships you will have to hand code that. I plan to fix this later. I can imagine dozens of ways how this could be improved. But some of them would make it complex, which I want to avoid. Add a comment and tell me what is your opinion and what would be your favorite improvement. Thanks!

Comments:

Looks very cool. I'd like to be able to select a CSS file in the wizard. That shouldn't be hard to implement. There could also be a default CSS file, just in case I don't have one.

Posted by Geertjan on shkurt 01, 2006 at 05:21 MD EST #

hi, Looks cool...I have been trying to do it...but I have some problem with installing the persistance library... I would like to do a small CRUD application in Java but unfortunately, I don´t understand anything...Please help me..Thanks

Posted by marco on shkurt 06, 2006 at 10:25 MD EST #

We are working on a set of tutorials, including one for Java SE (where you need to create a persistence library). This should be out soon, togeather with a tested build of NetBeans 5.5.

Posted by guest on shkurt 08, 2006 at 03:21 PD EST #

Awesome, Pavel. This does cover a lot of ground, going a long way toward getting one started in a new project. I think complexity should be avoided in favor of diversity. For example, I think it would be better to provide the same level of support, such as persistence units, for a variety of application servers, than to provide deep relationship configuration options in the wizard. Another example is providing more annotations for Glassfish/Sun AS (such as something like the Lucene EJB 3 extention from JBoss). It's very nice of you to ask for comments. Thanks! ==Leonard

Posted by sitongia on shkurt 08, 2006 at 09:27 PD EST #

Post a Comment:
Comments are closed for this entry.
About

pavel

Search

Categories
Archives
« prill 2014
DieHënMarMërEnjPreSht
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today