Binding an ObjectArrayDataProvider to a table

I wrote a JavaBean called Employee1 as follows

package employee1;

publicclass Employee1{

public String name;

publicint age;

public Employee1(String name,int age){

this.name = name;

this.age = age;

}

publicvoid setName(String name){

this.name = name;

}

publicvoid setAge(int age){

this.age = age;

}

public String getName(){

return name;

}

publicint getAge(){

return age;

}

}

I included the jar file of the above in the library

I inserted a Table control on my page

I dragged and dropped an ObjectArrayDataProvider into the SessionBean1

I included the following code in SessionBean1.java

public ObjectArrayDataProvider getObjectArrayDataProvider1(){

Employee1 emp1 =new Employee1("Sam Subramanian",57);

Employee1 emp2 =new Employee1("Mary Subramanian",26);

Map map =new Hashtable();

map.put("1001", emp1);

map.put("1002",emp2);

ObjectArrayDataProvider odp =new ObjectArrayDataProvider();

odp.setArray((Employee1[]) map.values().toArray(new Employee1[0]));

odp.setIncludeFields(true);

return odp;

}

When I tried to bind the dataProvider to the table, I couldnt see any of the fields. Could someone help me.

marysam

[2685 byte] By [marysama] at [2007-11-27 10:46:39]
# 1

Hi!

Read this:

http://blogs.sun.com/winston/entry/displaying_two_dimensional_data

http://blogs.sun.com/winston/entry/objectlistdataprovider_workaround

I hope it helps.

Thanks,

Roman.

-Grif-a at 2007-7-28 20:20:08 > top of Java-index,Development Tools,Java Tools...
# 2

Thanx Roman. I implemented the suggestions/advice and it worked

marysam

marysama at 2007-7-28 20:20:08 > top of Java-index,Development Tools,Java Tools...