Hi all ,
I am collecting a list of data from my database in my Action Class and populating it in an ArrayList viz "a" . Total I have 2 ArrayList's . one for storing EmployeeBean objects and other which stores (multiple)project names for each employee.
/*Here I am Storing Multiple Project Names under a single Employee */
Hashtable h = new Hashtable();
while(rs.next())
{
String [] param = {rs.getString("empid")};
h.put((String) rs.getString("empid"),new ArrayList());
}
if(h.containsKey((String) rs.getString("empid")))
{
ArrayList a = (ArrayList) h.get((String) rs.getString("empid"));
while(rsProj.next())
a.add(new String(rsProj.getString("p.projname")));
h.put((String)rs.getString("empid"),a);
}
/*Here I am storing each employee's data in a Bean */
ArrayList empList = new ArrayList();
try {
rs.beforeFirst();
rs.next();
while (!rs.isAfterLast()) {
EmployeeBean pb = new EmployeeBean();
pb.setEmpId(rs.getString("empid"));
pb.setEmpName(rs.getString("empname"));
ArrayList a = (ArrayList) h.get((String)rs.getString("empid"));
pb.setProjName(a); /*Store multiple proj names */
empList.add(pb);
rs.next();
}
request.setAttribute("empList", empList);
My EmployeeBean is as follows :
public class EmployeeBean {
private String empId;
private String empName;
private ArrayList projName;
public String getEmpId() {
return empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
public String getEmpName() {
return empName;
}
public void setEmpName(String empName) {
this.empName = empName;
}
public ArrayList getProjName() {
return projName;
}
public void setProjName(ArrayList projName) {
this.projName=projName;
}
}
Now i have to display this entire information for each employee in a table. So i have created a
jsp page for tht.
<c:forEach items="${empList}" var="empItem">
<tr width="100%" >
<td align="center" width="50">
<c
ut value="${empItem.empId}" />
</td >
<td align="center" width="123px">
<c
ut value="${empItem.empName}" />
</td>
<td align="center" width="145px">
<html:select name="empList" property="empList">
<html
ptions collection="empList.projName" labelName="empList.projName"/>
</html:select>
Now , I am stuck with how to display the data stored in the ArrayList "projName" . Can anyone solve my problem ???
Regards
SONAL