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 19 changed 1 line. |
AppGen requires that you create a POJO before generating your code. If you want to generate code straight from your database tables, you might take a look at [AppFuse Generator|http://appfusegenerator.dev.java.net]. |
[AppFuse Generator|http://appfusegenerator.dev.java.net] |