• 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

can anyone please give me an example for using value objects in struts

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
can anyone please give me an example for using value objects in struts
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you be precise in what you need ??
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you talking about Form bean?
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "official" name for this type of object is Transfer Object. Here is a link that explains about this pattern.

In Struts, the Transfer Object is used to transfer data between Model objects, or business objects and the view. Some have tried to make the ActionForm a transfer object, but this is not a good idea. You want your model objects to be completely free of any outside dependencies, and if you use a Struts ActionForm in this way, you make your model dependent on Struts.

The best practice is to create a POJO (Plain Old Java Object) that has no outside dependencies to use as a Transfer Object.

Here's an example:

1-User requests data for a single customer:
2-Request is routed to Action Class
3-Action instantiated a CustomerDAO object to get the data.
4-You have previously coded a CustomerDTO class to be used to transfer customer data to and from the model, and have coded a getCutomer() method on your CustomerDAO object that returns an instance of the CutstomerDTO object.
5- The Action class now has a reference to the instance of CustomerDTO that was returned. It now copies the data from the CustomerDTO into the ActionForm for the page you want to display. The BeanUtils.copyProperties() class can be useful for doing this.
 
The moth suit and wings road is much more exciting than taxes. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic