• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.
 
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic