I ask because most of the Struts apps I've seen don't bother with the DTO's, they just pass the ActionForm to the subordinate classes, or else pass them as parameters. It seems that regardless of what literature is telling is we should do, in practice (GENERALLY), people don't bother with the DTO's.

Have I just looked at the wrong apps? What are most people doing in this regard?

Form beans can be thought of as a special case of DTOs: they are the argument the client (web browser) passes to the remote method call (HTTP POST). So passing form beans directly to business logic is _almost_ reasonable, putting the dependency issue aside for now (form beans have to extend ActionForm).


The difference is, form beans are a model of the /user input/, and since there may be invalid inputs (for example: "asdfjkjkd" in a field that's supposed to be numeric) form bean fields often need to be Strings when the corresponding field in a "real" DTO would be a Date or Integer.

To deal with this, I've used a tool called XSnapshot (just released to SourceForge: http://xsnapshot.sourceforge.net) to generate form beans and other DTOs from XDoclet tags in a POJO data model. That way you get _both_ real DTOs and Form Beans without writing all the classes by hand, and you can copy between DTOs and form beans with BeanUtils.copyProperties.

-- Bill
--
Bill Schneider
Chief Architect

Vecna Technologies
5004 Lehigh Rd., Suite B
College Park, MD 20740
[EMAIL PROTECTED]
t: 301-864-7594
f: 301-699-3180


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to