Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences

Edit this page


Referenced by
Articles
Articles_cn
Articles_de
Articles_pt
Articles_zh
CreateActions
CreateActions_de
CreateActions_it
CreateActions_pt
CreateActions_zh
...and 14 more




JSPWiki v2.2.33

[RSS]


Hide Menu

AppGen


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 and Ben Gill. 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.

By default, AppGen will generate only Actions/Controllers, Action/Controller Tests, test data, i18n keys and JSPs. It will also configure Actions/Controllers for you. It uses the generic BaseManager and BaseDaoHibernate classes (configured as "manager" and "dao") to reduce the number of files that are generated. However, I realize that sometimes you will want to generate all the DAO and Manager classes (as well as their tests), so I've added that option too.

To see what AppGen does and how it works, see the AppGen Screencast.

To use the AppGen tool (after installing your web framework), perform the following steps:

  1. If you're using Hibernate, configure the mapping file for your POJO in applicationContext-hibernate.xml. If you're using iBATIS, you can skip this step.
  2. 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).
  3. 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.
  4. 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.

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: Struts, Spring, WebWork, JSF and Tapestry.

NOTE: If you'd like to generate all the DAOs/Managers/Tests, run ant install-detailed instead of ant install. Before you install anything, the files will be created in the extras/appgen/build/gen directory (in case you want to look at them before installing). If you just want to test the tool, you can cd to this directory and run ant test to see generate all of the code from the tutorials created.

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. ;-) 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



Go to top   Edit this page   More info...   Attach file...
This page last changed on 06-Nov-2006 13:52:59 MST by DougHays.