I am trying to add items to an arraylist. I know all about the arrayList.add(). However, the problem I'm running into is that I am using an object to hold the data (its summarization information for a report) of ExpenseItem, and I can't manage to get an arraylist to build properly so that it can be displayed. What I am doing is below:
So, as you can see, I bring in an external array, populate it from the form if data exists in the form, adding data to the array, and then writing it back to the form. It sounds like it should work, but I'm getting some really unexpected results when I do a println off the arrayList. I'm getting something similar to below:
Any ideas on how to make it one consistant arraylist?
Ugh; seems like a day object would have made that a little cleaner :(If getWeekInfo() returns a list (which the poorly-named wIc implies) you're adding a list into a list, producing a nested list. You may be thinking of java.util.Collection's addAll(...) method.
Additionally:Besides both comments being redundant, the first comment is also plain wrong and misleading.
Joined: Nov 03, 2008
Thanks for looking at it, but I think I may have sorted it out.
At the point in the code that calls the "storeValues()" I changed how the array is constructed.
At that point it constructs the array that gets passed to the storeValues. It also checks to see if the arraylist in the form is empty, if it's not it overrides the inital construction of the arraylist with the constructor that loads it from the form.
Then in the storeValues(), I'm getting the "Week Info Count" (your referenced badly named wIc). That gives me the position where to add another object (WCI) to the "overall" arraylist. I then set the arraylist in the form to the value of the new "local" arraylist.
Now if I could only get it to STOP re-appending the new data to the arraylist once the summary page is drawn, should the user hit the refresh button or some such, life would be golden, and I'd be down to format clean up.
Thanks for looking!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com