aspose file tools*
The moose likes Struts and the fly likes how to handle multiple iterates for the code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to handle multiple iterates for the code" Watch "how to handle multiple iterates for the code" New topic
Author

how to handle multiple iterates for the code

sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
Hi ranchers,

I want to dislay jsp in the following manner..

date1 date2 date3 . . .
--------------------------------------

data1 data2 data3 . . .
data12 data22 data32 . . .
data13 data23 data33 . . .
. . . . . .


--------------------------------------------------------

here is my action class code


public ActionForward getPatientVitals(ActionMapping mapping,
ActionForm form,HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException {

HttpSession session = request.getSession();
PatientVitalsDAO dao= new PatientVitalsDAO();
//int patientID;
String userName=(String)session.getAttribute("userName");
String pid=((Integer)session.getAttribute("patientID")).toString();

response.setContentType("text/html");
PrintWriter out = response.getWriter();
System.out.println("inside complaints retrieve method");
PatientVitalsForm pvform =(PatientVitalsForm) form;

List desc=dao.getVDate(pid); // retrieve list of Dates
session.setAttribute("PVitalDates",desc);

ArrayList data=new ArrayList();
data=(ArrayList)dao.retrieveVitalsRecord(pid);
//retrieve List of DTO objects for dates

session.setAttribute("PVitals",data);

return mapping.findForward(SUCCESS);


} // end getPatientVitals



------------------------------

here is my jsp page

<table width="20%" border="0" cellspacing="0" cellpadding="0">
<tr>
<logic resent name="PVitalDates" scope="session">
<bean:size id="dcount" name="PVitalDates"/>
<logic:greaterThan name="dcount" value="0">
<logic:iterate name="PVitalDates" id="vdates" type="ssl.phr.patientdemographics.dto.PatientVitalsForm">

<td width="2%" valign="top"><table border="0" cellpadding="0" cellspacing="0" >

<tr>
<td height="55" align="center" class="bodytext-black"><bean:write name="vdates" property="vitalDate"/><br>
<html:link action="/VitalsAction?methodType=getVital" paramId="vitalId" paramName="vdates" paramProperty="vitalId">Edit</html:link>

</td></tr>
<bean efine id="vitals" name="PVitals" scope="session" type="ssl.phr.patientdemographics.dto.PatientVitalsForm">

<tr><td height="26" >
<div align="center" class="bodytext-black"><bean:write name="vitals" property="bpSystolic"/></div></td></tr>

<tr> <td height="26" >
<div align="center" class="bodytext-black"><bean:write name="vitals" property="bpDiastolic"/></div></td></tr>
<tr> <td height="26" >
<div align="center" class="bodytext-black"><bean:write name="vitals" property="weight"/></div></td></tr>
<tr> <td height="26" >
<div align="center" class="bodytext-black">bean:write name="vitals" property="height"/></div></td></tr>
<tr> <td height="26" >
<div align="center" class="bodytext-black"><bean:write name="vitals" property="temperature"/></div></td></tr>
<tr> <td height="26" >
<div align="center" class="bodytext-black"><bean:write name="vitals" property="pulse"/></div></td></tr>
<tr> <td height="26" >
<div align="center" class="bodytext-black"><bean:write name="vitals" property="respiration"/></div></td> </tr>
</table>


</bean efine>
</logic:iterate>
</logic:greaterThan>
</logic resent>

--------------------------------

here i can only able to iterate dates but not able to iterate data related to dates..
help me out.

Thanks

Sreenivas
[ March 30, 2007: Message edited by: sreenivas jeenor ]
Christian Nash
Ranch Hand

Joined: Jan 17, 2006
Posts: 107
Can you tell me what the Pvitals and the Pdatevitals contain?? does these array lists contain any objects..if yes of what type.. please specify the action form and the object if any

You will need to use "indexed properties" for this. You will find a more complete explanation of what indexed properties are along with sample code by looking at question 6 in the JavaRanch Struts FAQ.
[ March 30, 2007: Message edited by: Christian Nash ]

- Christian
sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
Hi christain,

my action mapping is...
--------------
<action
path="/VitalsAction"
type="ssl.phr.patientdemographics.actionservlet.VitalsAction"
name="PatientVitalsForm"
scope="request"
validate="true"
parameter="methodType"
input="/vital.jsp">
<forward name="success" path="/PatientVitalFrame.jsp"/>
<forward name="edit" path="/VitalDateRetrival.jsp"/>

</action>
--------------------------

here are the methods i am using in action class
----------------------------------
public List getVDate(String pid)
{
Statement stmta=null;
ResultSet vitala=null;
ArrayList descriptiona=new ArrayList();
try{
con = connMgr.getConnection("sjo");
stmta = con.createStatement();
String sqla="select Vital_Date,Vital_ID from Patient_Vitals where Patient_ID='"+pid+"'";
vitala=stmta.executeQuery(sqla);

while(vitala.next())
{
pvdto=new PatientVitalsForm();

pvdto.setVitalDate(vitala.getString("Vital_Date"));
pvdto.setVitalId(vitala.getInt("Vital_ID"));
descriptiona.add(pvdto);
}

}
catch(SQLException sqEX){sqEX.printStackTrace();}
finally{
connMgr.freeConnection("sjo", con);
}

return descriptiona;
}

--------------------------

public List retrieveVitalsRecord(String pid)
{
PatientVitalsForm pvdto=null;
ResultSet rsf=null;
Statement stmtf=null;
ArrayList vitalmasterf=new ArrayList();
try{
con = connMgr.getConnection("sjo");
stmtf = con.createStatement();
String sqlf="select * from Patient_Vitals where Patient_ID='"+pid+"' order by Vital_ID desc";
rsf=stmtf.executeQuery(sqlf);
while(rsf.next())
{
pvdto=new PatientVitalsForm();
pvdto.setVitalDate(rsf.getString("Vital_Date"));
pvdto.setHeight(rsf.getString("Height"));
pvdto.setWeight(rsf.getString("Weight"));
pvdto.setBpSystolic(rsf.getString("BP_Systolic"));
pvdto.setBpDiastolic(rsf.getString("BP_Diastolic"));
pvdto.setTemperature(rsf.getString("Temperature"));
pvdto.setPulse(rsf.getString("Pulse"));
pvdto.setRespiration(rsf.getString("Respiration"));
vitalmasterf.add(pvdto);
}
}
catch(SQLException sqEX){sqEX.printStackTrace();}
finally{
connMgr.freeConnection("sjo", con);

}
return vitalmasterf;
}
-------------------------
sreenivas jeenor
Ranch Hand

Joined: Jan 09, 2005
Posts: 125
problem got solved.
Thanks christian for your time and support
 
wood burning stoves
 
subject: how to handle multiple iterates for the code