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

DTO and ActionForm

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my application which uses Struts,
I have some Data Transfer Objects(DTOs) which are all complex DTOs (ie it contains some objects also).

what I populate in the ActionForm is all strings input from the user.How to populate the DTOs from the ActionForms.
I think i cannot use BeanUtils.copyProperties(actionForm,dto) directly to copy the properties from my action form to DTO as the DTO contains some objects also.(These objects inside DTO has to be built from the data input by the user).

How to achieve this?

Also in the reverse,when displaying the details to user how to copy the properties from the DTO to action form?
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I write this code manually and put the methods in my action form. It is a bit of a pain but it works.

- Brent
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For BeanUtils copy to handle non registered converters, you can write custom converters. This had worked for most of the cases for me. But still after bean utils copy, I was also doing few explicit object creations and setting them to dto.

http://jakarta.apache.org/commons/beanutils/api/org/apache/commons/beanutils/converters/package-summary.html

http://www.javaranch.com/journal/200406/BeanUtilsDigesterAndTypeConversion.html
 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic