Creating a table from ArrayList (newbie question)

Hello all,

I've just started using Java Studio Creator 2.

What I need to do is to create a dead simple table where column entries are generated by a list. Say:

private ArrayList names = new ArrayList();

..

names.add("Peter");

names.add("Maggie");

and so on.

...

I've been searching through the forums and I found two solutions which do not work for me:

1) Changing the values of the defaultDataProvider manually: I don't know how to change table data. Seems to be complicated, am I wrong?

2) Using a List Data Provider:

listdataprovider.setList(names).

Then binding the column of the table to that listdataprovider.

Thanks a lot for your help,

Jess

[748 byte] By [Fluxkompensatora] at [2007-11-26 15:44:40]
# 1
Hi!You can use both methods.About first way You can read here: http://forum.java.sun.com/thread.jspa?threadID=5124772&messageID=9452195#94 52195And what exactly You don't understand in second way? Have You got any error or
-Grif-a at 2007-7-8 22:03:47 > top of Java-index,Development Tools,Java Tools...
# 2

I don't see how it works.

I tried following steps:

I have the Array list:

private ArrayList names = new ArrayList(2);

names.add("Peter");

names.add("Maggie");

then in the init of the pagebean:

listDataProvider.setList(names);

1) I place a "List Data Provider" somewhere in the page

2) The Properties window of listDataProvider1 shows : Data_ List names, so that seems to be fine

3) I place a table somewhere on the page

4) Under tableColumn1 -> StaticText3 I bind the text to listDataProvider

And well it doesn't work...I think step 4 is wrong. Don' understand how I can bind the thing. The problem is that the array will be generated automatically at runtime, otherwise I just could put the data in it.

Thanks for your help,

Jess

Fluxkompensatora at 2007-7-8 22:03:47 > top of Java-index,Development Tools,Java Tools...
# 3
I GOT IT. Well done. I followed this tutorial. http://blogs.sun.com/divas/entry/using_the_object_array_dataGreets
Fluxkompensatora at 2007-7-8 22:03:47 > top of Java-index,Development Tools,Java Tools...