Presented by developerWorks, your source for great tutorials
ibm.com/developerWorks
Collection collection = LocalFinderUtils.findAll("DeptBean");
return collectionToDeptValueArray(collection);
}
private DeptValue[] collectionToDeptValueArray(Collection collection){
ArrayList deptList = new ArrayList(50);
Iterator iterator = collection.iterator();
System.out.println("GOT THIS FAR");
while(iterator.hasNext()){
try {
Dept dept = (Dept)iterator.next();
DeptValue deptValue = new DeptValue();
deptValue.setId(dept.getId());
deptValue.setName(dept.getName());
deptList.add(deptValue);
}catch(Exception e){e.printStackTrace(System.out);}
}
return (DeptValue[])
deptList.toArray(new DeptValue[deptList.size()]);
}
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbRemove() {}
public void ejbCreate() {}
public void setSessionContext(SessionContext sc) {}
}
Notice that the
getDepartments()
returns an array of
DeptValues
. The
DeptValue
is just a POJO. In fact,
DeptValue
is a JavaBean, which is defined as
follows:
package bean;
public class DeptValue implements java.io.Serializable {
private String name;
private Integer id;
public DeptValue() {
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public Integer getId() {
Service enable EJB SessionBeans with the IBM ETTK
Page 25 of 33






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

servlet web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved