• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to handle multiple iterates for the code

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
sreenivas jeenor
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
problem got solved.
Thanks christian for your time and support
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic