You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Caroline Jen <ji...@yahoo.com> on 2007/06/08 14:13:36 UTC
What Would the Transfer Object Look Like If I Have a List of Objects
What would the "transfer object" look like If I have a
List of objects and each object has its properties?
Do I have a HashSet in my transfer object?
To clarify my question, let me give an example.
Say, I have a store and I sell music CDs. Each CD has
composer, title, and price as its properties. How do
I code the transfer object to pass data between J2EE
tiers?
In my JSF backing bean, I have java.util.List and I
use DataModel to display all CDs in tabulation:
import java.util.ArrayList;
import java.util.List;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
public class CDManagerBean
{
private String title;
private Float price;
private String artist;
private List cds = new ArrayList();
private DataModel cdModel = new ListDataModel();
{
cdModel.setWrappedData(cds);
}
// getters and setters
// addCD(), editCD(), and updateCD()
methods
}
I also have a CD java class:
public class CD implements java.io.Serializable
{
private String title;
private String artist;
private float price;
public CD(){}
// getters and setters
}
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/