• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Question in struts

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the Struts forum where those gurus can help you better.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic