aspose file tools*
The moose likes Struts and the fly likes Question in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Question in struts" Watch "Question in struts" New topic
Author

Question in struts

meera rao
Ranch Hand

Joined: Jun 30, 2005
Posts: 67
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

Joined: Jul 11, 2001
Posts: 15286
    
    6

Moving to the Struts forum where those gurus can help you better.


GenRocket - A Test Data Generation Platform
vijaya bharath
Ranch Hand

Joined: Jun 10, 2005
Posts: 66
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.


Regards,<br />Vijaya Bharath.<br />SCJP1.4 <br />SCWCD5.0
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question in struts
 
Similar Threads
How to Populate ArrayList
how to call stored procedure and also get parameters from the web page
how to call stored procedure and also get parameters from the web page
How to obtain a resultset using a stored procedure
Dynamic form table generation and naming of form fields