• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Designing DTO and ActionForm

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have queries to effectively design a component using struts and DTO pattern

1. Should i seperate IN DTO (goes to DAO) and OUT DTO( response from DAO) because the OUT DTO will have more fields or should it be only one DTO for one request/reponse flow.

2. Is it a good practise to use a existing DTO in other business functionality because some of the fields in existing DTO is similar to other business functinality.

3. Should a JSP use DTO to display the response from DAO or should it mapped to some ViewActionForm and then accessed in a JSP.

Thanks

 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, if you do not use EJB 2.x, you needn't to use DTO, you can use domain model directly.
Struts forces to extends ActionForm anyway. I recommend to use Spring Web MVC instead .

gurpreet singh wrote:
1. Should i seperate IN DTO (goes to DAO) and OUT DTO( response from DAO) because the OUT DTO will have more fields or should it be only one DTO for one request/reponse flow.


Needn't to separate.

gurpreet singh wrote:
2. Is it a good practise to use a existing DTO in other business functionality because some of the fields in existing DTO is similar to other business functinality.


Don't reuse just because it's "similar", do reuse when it's the same concept.

gurpreet singh wrote:
3. Should a JSP use DTO to display the response from DAO or should it mapped to some ViewActionForm and then accessed in a JSP.


What is ViewActionForm?
 
gurpreet singh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not using ejb2.x. In my component i have to pass value to DAO layer through facade. I thought i shouldn't pass ActionForm to DAO but to use DTO.

Can you please explain more on how to use Domain Model to achieved it?

By ViewActionForm i had mean't ActionForm to display response.
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

gurpreet singh wrote:I am not using ejb2.x. In my component i have to pass value to DAO layer through facade. I thought i shouldn't pass ActionForm to DAO but to use DTO.

Can you please explain more on how to use Domain Model to achieved it?


As I said, if you don't use EJB 2.x you can pass domain model directly to DAO, you needn't to create DTO classes.


It's like you have Customer model, using Struts it forces you to have CustomerForm.
You can pass Customer to CustomerDao like:


You needn't to create CustomerDto class.
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic