At line 1 changed 1 line. |
Versions 1.6.1+ include an AppGen Tool that can be used to generate all the classes needed to persist a POJO. This tool was based on contributions from [Lance Lavandowska|https://appfuse.dev.java.net/issues/show_bug.cgi?id=60] and [Ben Gill|https://appfuse.dev.java.net/issues/show_bug.cgi?id=78]. At first, I didn't want to add a code-generation feature like this b/c you'd end up with a 1-to-1 relationship between tables/pojos, DAOs and Managers. On most of my projects, I have far fewer DAOs and Managers than POJOs. |
[AppFuse] versions 1.6.1+ include an AppGen Tool that can be used to generate all the classes needed to persist a POJO. This tool was based on contributions from [Lance Lavandowska|https://appfuse.dev.java.net/issues/show_bug.cgi?id=60] and [Ben Gill|https://appfuse.dev.java.net/issues/show_bug.cgi?id=78]. At first, I didn't want to add a code-generation feature like this b/c you'd end up with a 1-to-1 relationship between tables/pojos, DAOs and Managers. On most of my projects, I have far fewer DAOs and Managers than POJOs. |
At line 5 added 2 lines. |
To see what AppGen does and how it works, <a href="http://demo.appfuse.org/appgen.html">see the AppGen Screencast</a>. |
|
At line 7 changed 3 lines. |
# Create your POJO (in the model directory) and <a href="#ref-CreateDAO-5">configure the mapping file</a> in {{applicationContext-hibernate.xml}}. |
# cd into the ''{{extras/appgen}}'' directory and run __ant -Dobject.name=Person -Dappgen.type=pojo__. In this example, the __Person__ class should exist in your {{model}} package. This generates all the files you create in the tutorials on this site (for your chosen web framework). |
# To install the generated files, run __ant install__. You can run __ant install -Dmodel.name=Person -Dmodel.name.lowercase=person__ if you want to do everything in one fell swoop. __WARNING:__ You might want to backup your project before you do this - or at least make sure it's checked into a source code repository. I've tested this code, and I think it works well - but it ''is'' modifying your source tree for you. |
# If you're using Hibernate, <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=CreateDAO#ref-CreateDAO-5">configure the mapping file</a> for your POJO in {{applicationContext-hibernate.xml}}. If you're using iBATIS, you can skip this step. |
# cd into the ''{{extras/appgen}}'' directory and run __ant__. You will be prompted to generate from a POJO or a Table. If you choose __pojo__, the .java file should already exist in your {{model}} package. If you choose __table__, Middlegen will be used to create a POJO from an existing database table. This generates all the files you create in the tutorials on this site (for your chosen web framework). |
# Finally, you will be asked to enter an application module or sub-package name. This is an optional feature that will allow you to organize your classes into sub-packages. For example, for a POJO "model" package of "org.appfuse.foo.model", just enter __foo__ when prompted. |
# To install the generated files, run __ant install__. You can run __ant install -Dappgen.type=pojo -Dobject.name=person__ if you want to do everything in one fell swoop. __WARNING:__ You might want to backup your project before you do this - or at least make sure it's checked into a source code repository. I've tested this code, and I think it works well - but it ''is'' modifying your source tree for you. |
At line 11 changed 1 line. |
The reason for the "lowercase" parameter is to rename the JSPs to begin with a lowercase letter. If I tried to rename them and change the filename programmatically, it took 1MB worth of BSF and Rhino JARs (+5 lines of code) and this just seemed easier. Speaking of JSPs - it's up to you to modify the {{*Form.jsp}} and make it look pretty. This is covered in Step 5 of each respective web framework's "Create Action/Controller" tutorial: <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=CreateActions#ref-CreateAction-5">Struts</a>, <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=SpringControllers#ref-SpringControllers-5">Spring</a>, <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=WebWorkActions#ref-WebWorkActions-5">WebWork</a>, <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=JSFBeans#ref-JSFBeans-5">JSF</a> and <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=TapestryPages#ref-TapestryPages-5">Tapestry</a>. |
After generating the view layer, it's up to you to modify the {{*Form.jsp}} ({{*Form.html}} for Tapestry) and make it look pretty. This is covered in Step 5 of each respective web framework's "Create Action/Controller" tutorial: <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=CreateActions#ref-CreateAction-5">Struts</a>, <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=SpringControllers#ref-SpringControllers-5">Spring</a>, <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=WebWorkActions#ref-WebWorkActions-5">WebWork</a>, <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=JSFBeans#ref-JSFBeans-5">JSF</a> and <a href="http://raibledesigns.com/wiki/Wiki.jsp?page=TapestryPages#ref-TapestryPages-5">Tapestry</a>. |
At line 15 changed 1 line. |
I encourage you to read the tutorials before using AppGen. That way you'll understand what's being generated for you and you'll only need to mailing list for [asking smart questions|http://www.catb.org/~esr/faqs/smart-questions.html]. ;-) Hopefully this tool will remove the pain of writing simple CRUD code and let you concentrate on developing your business logic and fancy UIs! |
I encourage you to read [the tutorials|Articles] before using AppGen. That way you'll understand what's being generated for you and you'll only need to mailing list for [asking smart questions|http://www.catb.org/~esr/faqs/smart-questions.html]. ;-) Hopefully this tool will remove the pain of writing simple CRUD code and let you concentrate on developing your business logic and fancy UIs! |
|
!!Related Tools |
|
[AppFuse Generator|http://appfusegenerator.dev.java.net] |