ObjectListData Provider work around - Sample Project
By winston on Feb 20, 2006
Few Creator users left comments in my previous blog Work around for Object List Data Provider design time problem, stating that they tried the work around but it did not help. So I decided to write a sample test project.
You can download the ObjectListDataProviderTest.zip from here
The simplest way to use ObjectListDataProvider is to add ObjectListDataProvider from the palette and then set your java.util.ArrayList of objects using the property sheet. Unfortunately due to some bugs in Creator this doesn't work. That is why some work around is needed until the bug is fixed in the future release.To test the downloaded ObjectListDataProvider test project, do the following
- Open the project in Creator 2.
- Clean and Build the application.
- Close the project.
- Reopen the project.
Note:The above steps are necessary because of some class loading problem in creator design time which will be fixed in future release.
- Now drop a table component on to the designer
- Bring up the table layout and select "nameListDataProvider" and close the dialog.
Now the table should display some sample data I added.
This is how I added the object list data provider to the application
- Added a class called "Name" with two properties "first" and "last" (Constructor takes two arguments)
(This is the object which holds the data)
- Added another class called "NameListDataProvider" which extends ObjectListDataProvider.
(The sample data is added in the constructor)
- Added a property called "nameListDataProvider" (of type NameListDataProvider) to the Session Bean.
BTW, if you make any changes to the classes "Name" or "NameListDataProvider" you must compile close and reopen project.
Note: As it is pointed in the comment below, to make it work at runtime, add the following statement to the session bean init() method
nameListDataProvider = new NameListDataProvider();