This week's book giveaway is in the Features new in Java 9 forum.
We're giving away four copies of Java 9 Revealed and have Kishori Sharan on-line!
See this thread for details.
Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question in struts  RSS feed

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

while ({
// this is my form bean ( with regular getter and setter methods
csf=new CountySummaryForm();
// this i am adding to an arraylist
//setting it as a request attribute.
Gregg Bolinger
Ranch Hand
Posts: 15304
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

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>
allEmployeesForm is the name given to outer

I think u got somethink.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!