Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question in struts

 
meera rao
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code below is part of my action class:
I code to access the stored procedure is written in another class, which returns the resultset. From this resultset, I am retrieving the fields and setting the variables in the form bean.
my form bean doesn't have any arraylist.
I am sending the arraylist as an request parameter to the jsp page.

now my question is,
1) Should i have an array list in my form bean, or is it ok to process the information this way and display it.
2) do we have to use DTO's
3)if we have to use arraylist in the form bean, how should i do it and how should i iterate through it from my jsp page.


// gets the resultset from a stored procedure
rs=cntyServ.getCountySummary(dateFrom,dateTo,conn);

while (rs.next()){
// this is my form bean ( with regular getter and setter methods
csf=new CountySummaryForm();
csf.setOfficeId(rs.getString("OfficeNum"));
csf.setTitleTransaction(rs.getInt("title_trans"));
// this i am adding to an arraylist
CountySumLst.add(csf);
}
//setting it as a request attribute.
request.setAttribute("CountySumLst",CountySumLst);
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the Struts forum where those gurus can help you better.
 
vijaya bharath
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Even me also came across this problem once. I declared arraylist in the FormBean. I need to get employees info from DB and need to print 5 rows each time and on clicking of previous and next i shud get the other 5.
For this i have declared outer from bean with the previous,next,rowcount(all Strings) and Employee(ArrayList). I have declared another formbean by name employee to store all the emp details. In that all the fields are Strings.
In jsp we can iterate thru the values of arraylist like this
<logic:iterate name="allEmployeesForm" property="employeeForm" id="employeeForm">

<td width="366"><bean:write name="employeeForm" property="firstName"/></td>
<td width="201"><bean:write name="employeeForm"property="designation"/></td>
</logic:iterate>
allEmployeesForm is the name given to outer

I think u got somethink.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic