Last weekend, we headed to Tucson, Arizona to visit with family. Here are some good pics from the trip - and one of Abbie with her new kitty.
Cool Trainyard |
El Charro |
Saguaro National Park |
Abbie giving Zoe a kiss |
One of the issues with using XDoclet to generate your Struts ActionForms (from POJOs) is that out-of-the-box, your Forms will not support indexed properties. This means that if you have a List on an object (this list will likely contain other objects/forms), you have to extend the generated form to add the necessary setters for indexed properties. For example, if you have an addresses List on a PersonForm, you would need the following in order to edit those addresses in Struts.
setAddresses(int index, Object address) {
this.addresses.set(index, address);
}
|
The worst part is that you need to populate the addresses list with a bunch of empty AddressForm objects before Struts' auto-population will succeed. If you were coding the PersonForm by hand, you could code a reset() method such as the following:
public void reset(ActionMapping mapping, HttpServletRequest request) {
this.addresses = ListUtils.lazyList(new ArrayList(), new ObjectFactory());
}
/**
* <code>StringFactory</code>
*
* @see org.apache.commons.ListUtils
*/
class ObjectFactory implements Factory {
/**
* Create a new instance of the specified object
*/
public Object create() {
return new AddressForm();
}
}
|
Now for the best part - I figured out how to generate this code with XDoclet, so any lists on your Forms will be indexed-property ready. By using <nested:iterate> in your JSP, you can easily CRUD you indexed properties. Pretty slick IMHO. The template is a bit much to put on this site, and it's long lines won't fit in a <pre> - so you can temporarily view the template here. I'll add a link to it in AppFuse's CVS once it shows up there. One thing you'll notice in this template is a little Velocity-lovin':
<XDtVelocity:generator>
#set( $method = $currentMethod.name)
## trim off the 'get'
#set( $objectName = $method.substring(3, $method.lastIndexOf('s')))
</XDtVelocity:generator>
Thanks to Erik on Merrick's blog for the quick Velocity/XDoclet howto. It was especially helpful since the XDoclet site has no documentation on this feature.
For all you my framework is better junkies - a clear explanation of how your framework handles indexed properties would be appreciated.
I just got an interesting SMS message from AT&T:
AT&T Wireless: Sony
Ericsson and AT&T
Wireless have sent
you a new T226
phone to replace
your current T68 -
no strings attached.
Questions? Call
800-500-3821.
Wierd eh? Is there something wrong with the T68i? I'll admit that the T226 looks a bit nicer, but when I get a new phone - I'd like to go all out. In other words, I'll be talking to Russ to get his recommendation.
From the struts-dev mailing list:
The Struts 1.2.0 Test Build is now available here:
http://www.apache.org/~martinc/struts/v1.2.0/
This is the first Struts build being made available following the same
test-and-release process that has been used successfully by the Tomcat
team for some time. It is *not* an official Apache release.
Once feedback has been collected on the stability and general quality of
this build, a determination will be made as to whether it should be
promoted to Alpha status.
You can reference the Struts site for a list of what's changed since 1.1. To further assist you (if you're upgrading from 1.1), you might want to check out how I did it back in October. I tested this build with AppFuse and all tests pass - I didn't even have to change a single line of code. For that reason, this is now the Struts version that'll ship with AppFuse 1.4.