Does anybody have any suggestions as to where the best place to convert my DTO into an ActionForm and vice versa? I'd like to put all the conversions for all the ActionForms in one class if that makes sense. Right now my conversion methods sit inside my DTO, but that doesn't seem right to me. I've thought of putting the conversion methods in the ActionForm superclass. It seems to me that there should be a class in our 'domain' layer (for our application that is where the business logic is performed) that should have these 'convertToActionForm(),convertFromActionForm()' methods. Any suggestions?
I would create a constructor in the FormClass which takes your Transfer object. Cause the DTO don't has to know anything about it, and for me this would be the nicest solution. But you can also create a super class with a method like
Joined: Jul 16, 2003
I like your ideas Oliver, except that the way I see them, they only perform the conversion one way. I would like to use the same type of conversion both ways. What I mean by this is if I used a constructor in the ActionForm class to convert the DTO to the ActionForm, I can't use a constructor in the DTO (and certainly not the ActionForm) to convert the ActionForm back to the DTO. Is there a common way that these conversions are done?
Joined: Nov 22, 2008
There is nothing to be said against doing the same for your DTO's or not?
I would recommend putting your conversion methods in their own class, not in the DTO or the ActionForm. They certainly don't belong in the DTO as the DTO should just be your data. Similarly, I wouldn't place them in the ActionForm either. As far as conversions going both ways, you really only need to write one conversion method, whether or not you are going DTO-to-ActionForm, or ActionForm-to-DTO. Just use the BeanUtils package. See my article Touring the Commons - part 1 in July's newsletter for more info on using the BeanUtils package. [ August 01, 2003: Message edited by: Jason Menard ]
Hi there, Is a data transfer object (DTO) a data object (DO) or value object (VO)? I always get confused on these issues because people seem to use them interchangeably although DO's or quite different than VO's. I am guessing a DTO is a VO since they are both used to transfer objects between nodes and tiers. If this is so, I usually situate a collection of delegate classes between the presentation and business tiers and assign it responsibility for creating and transfering objects TO the business tier and for seeding the request object with VO's returned from the business tier. In the business tier itself, I create a session bean whose sole purpose is to assemble VOs to return back to the client tier -- IF bean managed persistence is in place. If container managed persistence and container managed relations are in place, I let the entity beans create their own VOs. Darryl
Joined: Nov 09, 2000
Originally posted by Darryl A. J. Staflund: Is a data transfer object (DTO) a data object (DO) or value object (VO)?