Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between DTO and ActionForm

 
sudha javvadi
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Could anybody tell me the difference between dto and actionform. Do we need to use both of them in a application. I am doing some sample programs, so far I didn't use dto. In realworld what is the best practise?

Thank you,
Sudha.
SCJP 1.5
 
Chris Boldon
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ActionForms are coupled to your view.

DTO, or 'Data Transfer Objects' are a common object that is transfered between layers.

ie getting an object out of the database, you won't have an ActionForm, you'll have a different object. If you wanted to display that object on a JSP you would transfer the values to the ActionForm and render the page (well, I wouldn't, but I'm not going to make this complicated).

In the other direction, if you were going to save something to a database from a web form. You'd take the values off of the ActionForm, put them on a DTO and send it on its way to your service layer (well, again arguable if you have some sort of facade or other layer, but speaking basically).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic