If you've been fortunate enough to read Erik Hatcher's Java Development with Ant, you know that there's tons of good tips in it. I read it and I've been recommending it every since. Erik has been continuing development of the sample app for the book ever since it was released. I got many tips from Erik in developing AppFuse and I have to say, it really is a nice example. Maybe I'll get some more stuff now that it appears to have jumped from version 0.4 to 0.9! Here's a message Erik sent about the latest release.
All -
I'm proud (and worried about the support e-mails! :) to announce the
near-final release of a project demonstrating Ant, XDoclet, Struts,
JUnit, Cactus, and Lucene. Its called JavaDevWithAnt as it was written
for the book Steve and I co-authored and has been refined during
several presentations I've been giving on Ant, XDoclet and Struts.
The documentation is in draft stage, and my primary goal is to collect
feedback on polishing the documentation (and the application if there
are any bugs that surface). The site where I'm hosting the
distribution and documentation is:
http://www.ehatchersolutions.com/JavaDevWithAnt/
Please let me know if you try it out and have suggestions for
improvement, or just to let me know you tried it and hate it or love
it, etc. Feedback more than welcome! Direct feedback to me at
[email protected]
Erik
p.s. Since this e-mail is directed to the XDoclet, Lucene, and Cactus
lists, here is a brief teaser for you:
XDoclet - its used extensively, even using a custom tag handler to
generate starter JSP's from Struts form beans.
Lucene - my <index> Ant task is used to index text and HTML files, and
Lucene's API is used at run-time to query the index.
Cactus - StrutsTestCase is used, although no direct Cactus tests.
Happy information-overload! There's a lot there, but if I could figure it out - I'm sure you can. Erik - finally on Jaguar eh? What took you so long ;-)
I realize that having an ActionForm and a POJO with the same getters/setters is ridiculous, but please bear with me for this example. I have a Form and a POJO with Strings, Longs and Dates. The Longs and the Dates get converted into Strings when I get the data from the database using BeanUtils.copyProperties. This works great.
BeanUtils.copyProperties(userForm, user);
However, when going back, it's a different story - here's the ugly way:
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date dateChanged = format.parse(userForm.getDateChanged());
Date dateCreated = format.parse(userForm.getDateCreated());
user = new User(userForm.getUserId(), userForm.getPassword(),
Long.valueOf(userForm.getDesktopId()),
Long.valueOf(userForm.getCubeId()),
userForm.getCreatedBy(), dateCreated,
userForm.getChangedBy(), dateChanged);
While this works, it's ugly and a pain. I want something like the ActionForm-Value Object mapper. This mapper allows you to easily copy properties between VOs (or Hibernate Objects) and Forms, and vise-versa.
vo = FormToVOMapper.map(form, new ExampleVO());
So I could do something as simple as user = FormToVOMapper.map(userForm, new User()); I like this mapper and I used it on my last project, where it works great. However, I get the feeling that developers in the Struts Community are using something better - and I want to use it. So please, tell me what it is and lets figure out the best way to do this. Another method I've used in the past is to set the VO (or object) on the form itself, allowing for setting of Strings without copying - and setting dates on the form, to be manipulated by the setter. This framework worked great, and I was actually the happiest with it out of any of the above. Chime in and give me your opinions!