• 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

Struts, Logic:Iterate & ArrayList of ArrayList of Strings

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I was wondering if someone could help me with a problem I'm having. Part of my web application requires that I allow the user to choose the columns he wishes to perform an SQL query on.

Because I can't use <bean:write property=".../> tags (what columns the application shows in the table will change according to the query performed), I chose to create an ArrayList of ArrayLists of Strings where each string should represent one element of one row.

I declare my ArrayList of ArrayList of Strings as follows:


Inside of a while loop in the same class, I create new employee records:


The employeeList is then returned:


In my action class, I declare an ArrayList:


And I call on the method above to fill it with the appropriate data:


And set it to the session:


On my results page:
>

which returns a org.apache.JasperException:


If I iterate through the index, numerical values (0,1,2,3...18) will show with the correct number of records (19). If I bean:write the employee itself, it will show as [element1,element2...].

I'd really appreciate any help I can get!

Thanks in advance,
Alex
 
Alex Lau
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solved it

Thanks anyways =]
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm...nothing jumps out at me. I have not used generics much and never with nested collections. It seems like it should work fine. Is this valid code or just a post error?
ArrayList<String> employee = new ArrayList<Employee>();

About all I can say it to make sure you have taglib directive for logic. I am not sure how many hours I have wasted tracking down issues that turned out to be this simple mistake.

- Brent
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic