e enjte shkurt 02, 2006 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!
Posted by Geertjan on shkurt 02, 2006 at 01:21 PD EST #
Posted by marco on shkurt 07, 2006 at 06:25 PD EST #
Posted by gjh on shkurt 08, 2006 at 08:21 PD EST #
Posted by 192.18.42.11 on shkurt 08, 2006 at 11:21 PD EST #
Posted by sitongia on shkurt 08, 2006 at 05:27 MD EST #