wood burning stoves 2.0*
The moose likes Struts and the fly likes can anyone please give me an example for using value objects in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "can anyone please give me an example for using value objects in struts" Watch "can anyone please give me an example for using value objects in struts" New topic
Author

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

rakshini nithya
Ranch Hand

Joined: Jun 15, 2006
Posts: 39
hi
can anyone please give me an example for using value objects in struts
sreenath reddy
Ranch Hand

Joined: Sep 21, 2003
Posts: 415
can you be precise in what you need ??
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
Are you talking about Form bean?


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can anyone please give me an example for using value objects in struts
 
Similar Threads
Real World Example of Singleton Pattern
related links query
Example on struts database connectivity
non zero value
DynaForm