Re: ArrayList issue
On 21-02-2010 19:45, francan wrote:
I have this test working where it takes data from a Java class and
shows it in a JSP:
String targetItems = "test";
List pageItems = New ArrayList;
for(int i = 0;i< calculatedResults + 10;i++)
{
pageItems.add(targetItems + " " + i)
}
request.setAttribute(pageItems, "pageItems");
New ArrayList;
does not look as Java that compiles.
It is absolutely recommendable to copy paste actual
code into questions.
Otherwise non relevant error can easily cause the
troubleshooting to go in the wrong direction.
request.setAttribute(pageItems, "pageItems");
looks as if the arguments should have been swapped.
I would like to stop using test and put real data in using
an ArrayList but my attempt outputs a huge array of info for each
record:
ArrayList<TargetBean> targetItems = New ArrayList<TargetBean>
(TargetListing.getList());
List pageItems = New ArrayList;
for(int i = 0;i< calculatedResults + 10;i++)
{
pageItems.add(targetItems + " " + i)
}
request.setAttribute(pageItems, "pageItems");
I don't understand what this code is supposed to do.
You create a new list with each element being
the concatenated value of the original list, " " and
a number.
If I were to make a wild guess then you only need:
request.setAttribute("pageItems", TargetListing.getList());
Arne