Creator Tip: Work around for Object List Data Provider design time problem

Due to some design time source modeling and class loading problem, looks like Design Time support for Object Array and Object List Data Provider is broken in Creator 2. Here is a work around to solve this problem.

Assume you have a list of Search Data in an object called "SearchData", to display java.util.List of SearchData in a table using Object List Data provider do the following.

First create a Java Class called SearchDataProvider.

import com.sun.data.provider.impl.ObjectListDataProvider;

public class SearchDataProvider extends ObjectListDataProvider{
   public SearchDataProvider () {
       setList(<your java.util.list of data here>);
   }
}

In the SessionBean1.java add a property of type SearchDataProvider (Right click on the SessionBean1.java and select add -> property in the project windows). This action will add the following code to the SessionBean1.java

  private SearchDataProvider  searchDataProvider = new SearchDataProvider ();

   public SearchDataProvider getSearchDataProvider() {
       return searchDataProvider;
   }
      public void setSearchDataProvider(SearchProvider searchDataProvider) {
       this.searchDataProvider = searchDataProvider;
   }

Now add table component to the designer and select "Table Layout" from the context menu. In the dialog select "SearchDataProvider" in the drop down menu. You should see all the properties of your "SearchData" class as column in the Table column. The data from your "SearchData" objects will be displayed in the table.

Comments:

After going a bit mad about the obvious bug with the ObjectListDataProvider I tried this workaround but it neither helps. My self-written DataProvider (which extends ObjectListDataProvider) simply does not appear in the selectbox to choose the data provider for the table. I only see the defaultTableDataProvider. Any mor hints? (Or even better if Sun could provide a hotfix for ObjectListDataProvider) Thanks! Martin

Posted by Martin Schäfer on February 18, 2006 at 06:02 AM PST #

I have run into the same problem, as I am sure everyone will who Downloads the Field Guide book and trys working through the tutorials. Is there a public repository that lists known issues, so that when we run into things like this we can tell if it on a list of things to fix? The biggest problem I have now, besides the List Data Provider, is trying figure out what options where selected for each drop down list component in a table. Seems like it only maps to one object in Creator no matter how many HTML objects are actually created. I can set the list options individually in each row.

Posted by joe paladin on February 19, 2006 at 09:03 AM PST #

I just wanted to say that the first person commenting here was correct, this work around does not work, I had to try it myself thinking maybe there was a slight chance.

Posted by Joe Paladin on February 19, 2006 at 09:27 AM PST #

Hi Prakash, I am using ur table tip "How to create single selectable row Table component " Actually I bound a web service method to my table which has a return type primitive array. The problem is after selecting a row how do I fetch a particular cell value without any action performed events. I mean using scripts or any thing else... Now I fetch using some code : given below which was written in a button action. java code: int selectedRows = getTableRowGroupConactsBasedOnCat().getSelectedRowsCount(); RowKey[] selectedRowKeys = getTableRowGroupConactsBasedOnCat().getSelectedRowKeys(); for(int i=0; i< selectedRowKeys.length; i++){ rowId = Integer.parseInt(selectedRowKeys[i].getRowId()); } tablePhaseListener.keepSelected(true); RowKey rowKey = contactSystemServiceGetContacts31.getRowKey(String.valueOf(rowId)); FieldKey fieldKey = contactSystemServiceGetContacts31.getFieldKey("contactID"); String selCellVal = contactSystemServiceGetContacts31.getValue(fieldKey, rowKey).toString(); Coz. If any action event occured in my page... the table value keeps on changing in random order. so the selected row or record changing unanimously. Prakash, Kindly reply me the solution with ur e-mail id... Kalki.

Posted by Kalki on April 09, 2006 at 03:36 PM PDT #

hi Prakash, I am using ur tip " How to create single selectable row Table component" In that I changed Trip Id column to Radio button component. How do I get a selected cell value (Trip ID) using javascript. I can able to get the text field value using javascript. But how do I use the value in java page.

Posted by Ashokkumar on April 16, 2006 at 10:34 PM PDT #

Prakash - I too have tried your tip. I do see the extended provider in the drop down of Table Layout but the member fields of SearchData do not appear..please can you provide a more detailed example as this fundemental bug may cause us to not use creator 2 in our current project. Many thanks for your efforts!

Posted by James on May 22, 2006 at 05:32 AM PDT #

Try putting your POJO's and DataProvider classes in a separate project. I think the data binding may have some class loader issues. In the Projects window, right-click your main project node, and choose Properties from the contextual menu. Within the Project Properties dialog box, in the tree on the left, click on Libraries. Then click the Add Project button. Now, add in the project with the POJO's/DataProvider declarations. Looks like the workaround works wonderfully after that.

Posted by Sandeep on October 12, 2006 at 03:11 AM PDT #

Try close and reopen the project. The data provider will be appear.

Posted by vaxim on October 21, 2006 at 06:21 PM PDT #

a

Posted by guest on January 03, 2007 at 01:55 PM PST #

I Try close and reopen the project many times but it not work always. I hope the sun fix it , because is not possible develop that way.

Posted by andre on July 13, 2007 at 12:56 AM PDT #

Hi, Im making a table within a table. Meaning, 2 different table and 2 different objectlist provider.
My question how can i view my table with the following condition? Please help. thanks.

Posted by Christian Henry Reyes on August 20, 2007 at 04:36 PM PDT #

i tried clean and build project then close and reopen project, that worked.

Posted by wowerng on January 02, 2008 at 11:06 AM PST #

After struggling to get OLDP working...I got a real success!

Please let me know if some body is still struggling and I can provide Sun Creator Proof Of Concept project on OLDP!

Thank you

Abhay
abhaychitre@gmail.com

Posted by Abhay Chitre on March 12, 2008 at 04:37 AM PDT #

Hi Abhay, if you are using Netbeans 6.0 or later you don't need OLDP at all. You can directly bind List of Object to Table as I mentioned in my blog http://blogs.sun.com/winston/entry/nb6_table_binding_enhancement

Posted by Winston Prakash on March 12, 2008 at 05:30 AM PDT #

I am struggling with a related issue ... needing to display a list of entities I get back from an session ejb into a dropdown. The data binding on the the dropdown doesnt allow me to select the list (I have getters and setters for it). Do I need to use the OLDP route for this??

Im on nb6.1

Posted by Rambo on May 14, 2008 at 10:15 AM PDT #

Hi Prakash, I'm doing migration from NetBeans 5.5 to 6.1. Your workaround (clean, close IDE, reopen, delete private folder ecc... don't work!). If I build my project I don't see in the visual editor many components, expecially TableRows! There is a workaround for this problem?!?!? Thanks :-)
Chris

Posted by Chris on May 19, 2008 at 07:49 PM PDT #

Std OLDP doesnt work. Anyone know if this still an issue with NB6.1?

Posted by Rambo on May 20, 2008 at 01:19 PM PDT #

Hi Rambo, You don't have to use OLDP directly in NB 6.1. See my blog http://blogs.sun.com/winston/entry/nb6_table_binding_enhancement#comments

Posted by Winston Prakash on May 23, 2008 at 12:03 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today