NB 6.0 Visual Web Table Component Binding Enhancements To Use POJOs

Netbeans 5.5.1 Visual Web Table Component allows binding only via Data Providers such as CahcedRowsetDataProvider. While working with Hibernate or JPA or Spring framework, you must be dealing with Plain Old Java Objects (POJOs). If you have List or Array of  POJOs, then only way to bind them to the Table Component is by creating ObjectListDataProvider or ObjectArrayDataProvider. Also, due to a bug in Netbeans 5.5.1 Visual Web designtime, you may have to use the work around I explained in one of my earlier blogs - Work around for Object List Data Provider design time problem.

We have changed couple of things in Netbeans 6.0 related to Table Component binding.

  • Creation of an Object Array or a List Data Provider is not necessary to bind a Table Component to POJOs
  • We have eliminated the need for compile, close and  open the project ceremony after creating the POJOs in the project. It is enough to compile the project and may be refresh the designer if the page is already opened. (My wish is to eliminate even the need for compiling the project, by source modeling all the Java sources in the project. The main obstacle is performance. So, currently we handle only compiled objects.)

Binding Array of POJOs

In order to bind Array of POJOs, first you need to create a property in the backing Page Bean or some other Managed Beans (Ex. SessionBean1), that returns Array (say myArray) of the Specified Object (say MyObject). To create the property

  • Type the line private MyObject[] myArray;
    • Right click on this line and select the action "Generate Code"
    • In the resulting popup menu select "Getter and Setter"

The above would add the code to the Java source as

private MyObject[] myArray;
public MyObject[] getMyArray(){
     return  myArray;

public void setMyArray(MyObject[] myArray){
     this.myArray = myArray;

Now to bind myArray, compile the project, refresh the designer and bring up the Table Layout. You will find myArray listed in the drop down list as show in the picture below.

Array of POJOs binding

Binding List of POJOs

Binding List of POJOs is more or less same as binding arrays with one important difference.  In case of Array of POJOs, the Array itself has information about the type of the POJO. However, in case of List of POJOs, the Table Component can not determine the type of the POJO, since List is one of the generic interface in the Collections Framework. In order to solve this problem, Java Generics comes handy. You can specify the type of the POJO, that will be added to the list, to the design system using a parameterized List as shown below. This is really useful if the List will be populated lazily during runtime. Add the myList property to the backing Page Bean

  • Type the line private List<MyObject> myList;
    • Right click on this line and select the action "Generate Code"
    • In the resulting popup menu select "Getter and Setter"

This would add the code to the Java source as

private List<MyObject> myList;
public List<MyObject> getMyList(){
     return  myList;

public void setMyList(List<MyObject> myArray){
     this.myList = myList;

Similar to binding Array of POJOs, bring up the Table Layout and  myList will be listed in the drop down list as show in the picture below. Don't forget to compile the project and refresh the designer.

List of POJOs binding

Note: Even though explicit creation of Data Provider is not necessary, Table Component implicitly creates the Data Provider.  You might want to get information from the underlying Data Provider. For example if you have a column with Button or CheckBox or RadioButton, you might want to find the location of the selected row. Here is a code that would help you to do that.

    RowKey[] selectedRowKeys = getTableRowGroup1().getSelectedRowKeys();
MyObject[] myArray = getSessionBean1().getMyArray();
int rowId = Integer.parseInt(selectedRowKeys[0].getRowId());
MyObject myObject = myArray[rowId];


Thank you for the new enhancements.
I am wondering if the visual table component in NB 6 can bind some javax.faces.model.DataModel ojbects, I can see some no visual JSF/JPA examples doing that way. Meanwhile I would like to know if some list components like dropdown list can bind Array or List objects as the table component does, because those kinds of components are equally useful as table.
Thank you!

Posted by Kane Li on October 14, 2007 at 09:11 PM PDT #

I've tried the array approach, the list approach and the (explicit) DataProvider approach. The list approach won't work, no matter how many times i recompile, refresh the visual editor or restart netbeans. I've tried the following code onn both the session bean and the page's backing bean; any ideas? Thanks! -- Erik

private List<InvoiceDetail> invoiceDetailList;

public List<InvoiceDetail> getInvoiceDetailList() {
return invoiceDetailList;

public void setInvoiceDetailList(List<InvoiceDetail> myInvoiceDetailList) {
this.invoiceDetailList = myInvoiceDetailList;

Posted by Erik on October 19, 2007 at 12:06 AM PDT #

Hi Erik, which version of NB you are using?. This feature is available only after Netbeans 6.0 Beta1 or later. I tried now, it works for me.

Posted by Winston Prakash on October 19, 2007 at 12:22 AM PDT #

Hi Winston, thanks for your reply. I'm using 6.0beta1.

Posted by Erik on October 19, 2007 at 12:32 AM PDT #

Erik, post your sample code at the nbuser alias (put VWP in the subject), I'll take a look at it.

Posted by Winston Prakash on October 19, 2007 at 12:36 AM PDT #

Winston, my direct list aproach works fine, but I can't find getDataProvider() method in com.sun.webui.jsf.component.Table
Any ideas?
Product Version: NetBeans IDE Dev (Build 20071005123835)

Posted by v.m.kotov on October 23, 2007 at 05:19 AM PDT #

Ha!, my bad. The correct way to get the TableDataProvider is using TableRowGroup Component method tableRowgGroup.getTableRowDataProvider().getTableDataProvider();

Posted by Winston Prakash on October 23, 2007 at 08:00 AM PDT #

Thanks for reply, but getTableRowDataProvider() - has protected access, so I can't call it from for ex. Page1.java.

Posted by v.m.kotov on October 23, 2007 at 08:37 AM PDT #

Hi and thanks for your informative article.
I am having pretty much the same problem with v.m.kotov.
I am using Netbeans 6.0 Beta 1 on a JavaEE5 project. I have created a table with a binding to an ArrayList of POJOs. I now want to add a "delete row" button on each row of the table. I obviously need to access the underlying data provider in order to delete the row, based on the current RowKey. However, I cannot find the getTableRowDataProvider() or getTableDataProvider() methods you are talking about...

Any help would be very much appreciated...

Posted by Zzzzz on October 24, 2007 at 02:35 AM PDT #

OK I found a solution to my problem.
I created a subclass of TableRowGroup and modified the rowGroup of my table so that it is an instance of this subclass. I created a method deleteRow(RowKey rk) in the subclass. The subclass can now access the protected method getTableRowDataProvider(), so I can get a reference to the data provider and delete the row.
Note that I also had to cast the data provider to ObjectListDataProvider, and call commitChanges() in order for the deletion to propagate to the List and the table...

(Hope that this approach also helps v.m.kotov)

All this would be much simpler if getTableRowDataProvider() was public. So is there any good reason that it is declared as protected?


Posted by Zzzzz on October 24, 2007 at 09:45 PM PDT #

Table Component is maintained by Woodstock team only the design time support is maintained by VW team. I talked to Woodstock team. Looks like they did not think there is any need to get back the dataprovider to manipulate the data given to Table Component. He said the possible solution would be use TableRowGroup.getSourceData(). But looks like there may be need for proper casting etc. BTW, it is possible to update, delete, append with out getting back the Dataprovider from table. Look at the article I wrote (which uses Array of Objects obtained from database via JPA) http://www.winstonprakash.com/articles/netbeans/JPA_Add_Update_Delete.html

Posted by Winston Prakash on October 25, 2007 at 12:25 AM PDT #

Thanks Winston, very usefull link, I sugest to replace Note about getTableDataProvider() with smth like this:
RowKey[] selectedRowKeys = getTableRowGroup1().getSelectedRowKeys();
MyObject[] myArray = getSessionBean1().getMyArray();
int rowId = Integer.parseInt(selectedRowKeys[0].getRowId());
MyObject myObject = myArray[rowId];

Posted by v.m.kotov on October 25, 2007 at 07:31 AM PDT #

Thanks. I added your suggestion.

Posted by Winston Prakash on October 25, 2007 at 08:12 AM PDT #

Hi Winston

Thanks for your tip it is very useful for me .

Posted by saeed on October 27, 2007 at 10:59 PM PDT #

Hi Winston.
how can i link a ejb (entity class, in web service) with a Table in visual WEB pack? i want to write acces data model and then use in a VWP project, mobile aplicattion or J2se.

Pd: Sorry for my horrible english. i will study english the next year. it is my promise

Posted by javiersinnada on November 28, 2007 at 07:07 AM PST #

Hi Javier, take a look at my tutorial http://winstonprakash.com/articles/netbeans/JPADataBinding.html. In this one I have separated out the data access as separate model project and view as another web application. You might want something like that, I suppose.

BTW, your English is not that bad :)

Posted by Winston Prakash on November 29, 2007 at 01:25 AM PST #

Hi Winston, i was working on the jpa y vwp tutorial(http://winstonprakash.com/articles/netbeans/JPADataBinding.html), i have a problem, it is when the connection is with postgres...that's the error:

(Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/sample
Error Code: 0
at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:305)
at oracle.toplink.essentials.sessions.DefaultConnector.connect(DefaultConnector.java:102)
at oracle.toplink.essentials.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:184)

note: if drop the dataproviders normally with the same connection it works at perfection.

Posted by Gustavo on December 12, 2007 at 03:38 AM PST #

Hi, thanks for those tutorials, it's realy help me to understood how to manged with db.
I had similar problem to Gustavo with postgresql database, also glassfish displaied that it can't find suitable driver.
Realy 2 days with it, and at last found what's going on, simple you have to add to classpath in glassfish admin console fully-qualified path name for the driver’s JAR file. (Application Server->JVM Setting Tab->Path)

Posted by Jakub on December 27, 2007 at 01:22 AM PST #

[Trackback] Bookmarked your post over at Blog Bookmarker.com!

Posted by weblog on January 16, 2008 at 05:57 PM PST #

Is it possible to show data from an underlying pojo in the table?
I.e. PojoA has a PojoB property and I want to show a property from PojoB but it's PojoA that's bound to the table. Like this: pojoA.getPojoB.getName().

Posted by Mats on January 29, 2008 at 09:32 PM PST #

You try something like ..

Create a method in the page bean

public String getName(){
PojoB pojoa = (PojoA) getValue("#{currentRow.value['PojoA.PojoB']}");
return pojoa.getName();

and then bind this method to the static text in the table column.

Posted by guest on February 01, 2008 at 05:07 AM PST #

I can't seem to get the table to bind to a list of objects (followed all your instructions). Array of objects works fine as the table in the UI recognizes it as a possible source. When trying to bind to List<MyObject> getMyObjects the table in the UI doesn't see it.

Posted by Mark on February 05, 2008 at 10:41 PM PST #

When binding a Table component to an array/list of POJO, how does the component see properties that are in the subclasses of the POJO? Since the binding is done at design time, the subclass properties don't appear in the "Bind to Data" dialog. That is, if my POJO is Person, which has Employee as a subclass, how do I bind a property of Employee, say worksFor, to the Table component? Any help is greatly appreciated.

Posted by Billy Lim on March 27, 2008 at 12:54 AM PDT #


I discovered the following bug while trying to bind some entity classes to a VWP table in Netbeans 6.1 beta:

1. NB does not recognize and show the bean for an Array in Navigator and Dropdown (Table Layout/Get Data From) if the class is not in the same project.
2. NB does not recognize the fields when binding a generic List<E> if class E is not in the same project.

The project containing the entity classes is, of course, added.


Posted by Markus on March 27, 2008 at 11:38 PM PDT #

Markus, a issue has been filed against the problem you mentioned and being investigated.

Posted by guest on April 01, 2008 at 12:50 AM PDT #

I'm using Netbeans 6.0.1 and NB doesn't recognize my list of beans if the entities are not in the same project. Works well with array of beans though

Posted by guest on April 02, 2008 at 11:23 AM PDT #

Buen dia Doctor.

tengo una inquietud mas, como se podria hacer una tabla editable con woodstock utilizando una list cuando vinculo la tabla con un ObjectListDataProvider yo lo se hacer pero ahora quisiera probar cuando vinculo la tabla con un simple List,

este es el codigo de la jsp
<webuijsf:table augmentTitle="false" binding="#{Page1.table1}" id="table1"
style="left: 30px; top: 70px; position: absolute; width: 450px" title="Table" width="0">
<webuijsf:tableRowGroup binding="#{Page1.tableRowGroup1}" id="tableRowGroup1" rows="10" sourceData="#{SessionBean1.lista}" sourceVar="currentRow">
<webuijsf:tableColumn binding="#{Page1.tableColumn1}" headerText="codigo" id="tableColumn1" sort="codigo">
<webuijsf:staticText binding="#{Page1.staticText1}" id="staticText1" text="#{currentRow.value['codigo']}"/>
<webuijsf:tableColumn binding="#{Page1.tableColumn2}" headerText="nombre" id="tableColumn2" sort="nombre">
<webuijsf:textField binding="#{Page1.textField1}" id="textField1" text="#{currentRow.value['nombre']}"/>

este es la declaracion de la List en en sessionBean1

List<newPruebaDto> lista=new ArrayList<newPruebaDto>();

public List<newPruebaDto> getLista() {
return lista;

public void setLista(List<newPruebaDto> lista) {
this.lista = lista;

y la clase newPruebaDto tiene esta declaracion

public class newPruebaDto implements Serializable {
private String codigo;
private String nombre;

public newPruebaDto(String codigo, String nombre) {
this.codigo = codigo;
this.nombre = nombre;

public newPruebaDto() {

public String getCodigo() {
return codigo;

public void setCodigo(String codigo) {
this.codigo = codigo;

public String getNombre() {
return nombre;

public void setNombre(String nombre) {
this.nombre = nombre;

agradezco la ayuda porfa

Posted by Jaider rodriguez lozano on April 17, 2008 at 11:19 AM PDT #

Hi Winston,

Thanks a lot for all your tutorials, they have been a great help. I've been having an issue with buttons in a column of a table. When the table is bound to an ObjectListDataProvider the button actions fire appropriately, however if I change the binding to the List, rather than the DataProvider, the button events stop firing.

Any help would be greatly appreciated.


Posted by guest on April 20, 2008 at 11:06 AM PDT #

No matter if I use an Array or an ObjectListDataProvider, I do not get my table sortable. That is, the sort buttons in the column heads are not provided. What can I do about that?
Thank you for your hints,

Posted by Stefan Bley on April 27, 2008 at 09:13 PM PDT #

Hi Winston,
I would like to know if it is possible to use a table component bind to an array object locate on request bean?
I am executing a SQL and saving the result in an array object, however it only work if I locate the array on session bean, but this seems inefficient because all data remain on session even when this is not used

Hola Winston,
Me gustaria saber si es posible usar un table component(incluyendo las funcionalidad de ordenamiento y paginacion) que obtenga los datos de un array ubicado en request?
Actualmente yo estoy ejecutando un SQL y guardando los resultado en un array, para posteriormente cargar los datos en el table component, sin embargo esto solo funciona si localizo el array en Session, ya que si lo localizo en Request seria necesario ejecutar el query cada vez que se pagina o se ordena el listado.
El problema es que ambas cosas me parecen ineficientes, si guardo todos los resultado en sesion estos van a permanecer alli aun cuando no sean usados y si lo guardo en request ejecutaria el Query (select) cada vez que se pagina o se ordena el listado, entonces la pregunta es:

Es posible hacer permanecer los datos cargados en el table component en request sin que sea necesarios recargarlos nuevamente cada vez que se pagine o ordene el listado?

Posted by Roger on April 29, 2008 at 12:14 AM PDT #

Hi Winston,

I am also experiencing the same error as Judd. If I use a List<MyObject> instead of a DataProvider, any buttons in the table columns will not fire.

Is there a solution for this problem?



Posted by Josh on May 01, 2008 at 06:29 AM PDT #

Hi, Winston!

I have a POJO with some properties and i can bind it to a table with no problems. I want to diplay one of the properties in that table in text fields, instead of static text, so the user will could change the values. That's ok too. My question is how could I update my pojo list with the values entered by users? If I work with ObjectListDataProvider, I just use commitChanges().

Thanks in advance!

Estevão Lisauskas

Posted by Estevão on May 17, 2008 at 11:32 PM PDT #

All the names of array properties of my java class object are displayed as table-component column titles. However, the contents (values) of these arrays are not displayed on the table. The table says "No items found"

Has anyone else apart from Dr. Winston Prakash succeeded in having the table component display contents of array of pojos?

Posted by Raymond Rugemalira on May 21, 2008 at 03:05 AM PDT #

My problem appears to be similar with the poster above, Raymond Rugemalira.

I am using the array of objects method. After I Bind to Data to a table component (as described in Winston's personal site), but when I run it I am not able to see the data inside the table. In the design view, I can see that the binding is done, but only when I run it, it says on the table "no items found".

It'll be nice if someone can share a solution, as I can do that part two of this tutorial to add, delete & update.

Posted by Marat on July 01, 2008 at 06:16 PM PDT #

The "binding enhancements" for List does work for the woodstock table components, but not for the standard DataTable component. What am i missing? Thanks in advance.

Posted by ts on July 12, 2008 at 06:01 AM PDT #

Hi Winston,
thanks for these helpful information.

I would like to know if there's a way to \*really\* bind a webuijsf:table with a List of POJO.

I have a table with some textfields in it.
The problem I'm facing is that \*real binding\* does not take place ( framework should update the underlying List ), even if the List is in session scope.

My set() methods never get called ... so I need to grasp data \*by hand\* from HttpServletRequest using inside-table components' client ids, and put back
data into session list ( calling every set() method on my POJO ).

Hope there's a less \*hard\* method.
Thanks in advance


Posted by Tonyweb on September 18, 2008 at 05:20 PM PDT #

hi friends ,
it would be great if you could tell me how to add the manually data to above mention solution , because i have a problem that, i want to display xml prase data in woodstock table .But i have created a class exactly how you mentioned in this solution page . but i have no idea where to input this prased xml data which is stored in a array so that i could displayed in table.

Posted by jaysonkn on October 02, 2008 at 03:40 PM PDT #

A simple questionb about netbeans 6.5rc2. HOW DO I RESFRESH THE DESIGNER???

Posted by arragon99 on November 10, 2008 at 01:00 AM PST #

oh ja even I found the possibility to refresh the jsp site via the navigator view. ;) Sorry for that

Posted by arragon99 on November 10, 2008 at 09:24 PM PST #

Hi winston, I need your collaboration with a performance problem relate to the Table component,
it load all data and the page its too slowly
Currently are only 200 records

How can I avoid that this component load the all data?

It should load the data when it paginates
Thanks in advance
Sorry for my bad English

Posted by rogerzam on November 11, 2008 at 06:10 AM PST #

I was able to bind the table to myArray, but I don't see any information. For example, myArray is a String array that contains "1", "2", and "3". The table fields say CASE_INSENSITIVE_ORDER, bytes, and empty. The information I get is 3 rows of jibberish. How can I put the data that I want in my table using an array? I've been working on this for hours. Any help would be much appreciated.

Posted by Luke on November 13, 2008 at 11:14 AM PST #

Hi Winston, I am using NB6.1, it seems to work great, and thank you very much for all your tutorials. Everything seems to work fine. My question is, using java persistence, how do I populate a drop down list. I have no problem populating a table. Do I still need to drop a table onto the drop down in the design panel, or can i use the entities to populate the list. thanks

Posted by Jon on December 09, 2008 at 06:46 AM PST #

Previous question re-phrased. How to populate drop down list from a database table using java persistence?

Posted by jon on December 09, 2008 at 08:00 AM PST #

I am using Netbeans 6.5 with the Woodstock components that come with it. So far I have managed to bind woodstock tables to my custom objects as shown in your article with the following method:

private List<MyObject> myList;
public List<MyObject> getMyList(){
return myList;
public void setMyList(List<MyObject> myArray){
this.myList = myList;

For some reason though, yesterday, I created a new page, followed the same usual steps. Only this time, the new woodstock table I dropped on the page was not listing my List in the "Get Data From" dropdown, when I tried to Bind To Data. On the other hand, binding to MyObject[] myArray still works as usual.

I then went to other pages where I had successfully bound tables to List<T>. Running the pages worked at runtime. However when I tried to access the 'Bind To Data' menu, Netbeans was throwing a Null Pointer Exception (on every table) as follows:

at com.sun.webui.jsf.component.table.TableBindToDataPanel.setTableDataProviderDesignState(TableBindToDataPanel.java:211)
at com.sun.webui.jsf.component.table.TableBindToDataPanel.initialize(TableBindToDataPanel.java:179)
at com.sun.webui.jsf.component.table.TableBindToDataPanel.<init>(TableBindToDataPanel.java:84)
at com.sun.webui.jsf.component.customizers.TableBindToDataCustomizer.getCustomizerPanel(TableBindToDataCustomizer.java:55)
at org.netbeans.modules.visualweb.insync.CustomizerDisplayer.show(CustomizerDisplayer.java:115)
at org.netbeans.modules.visualweb.insync.ResultHandler.handleResult(ResultHandler.java:205)
at org.netbeans.modules.visualweb.insync.action.AbstractDisplayActionAction.invokeDisplayAction(AbstractDisplayActionAction.java:145)
at org.netbeans.modules.visualweb.insync.action.AbstractDisplayActionAction.access$200(AbstractDisplayActionAction.java:94)
at org.netbeans.modules.visualweb.insync.action.AbstractDisplayActionAction$SingleDisplayActionAction.actionPerformed(AbstractDisplayActionAction.java:272)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1220)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1261)
at java.awt.Component.processMouseEvent(Component.java:6041)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5806)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4413)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2440)
at java.awt.Component.dispatchEvent(Component.java:4243)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

I have tried reinstalling Netbeans 6.5, to no avail. I have also removed the '6.5' folder in my Documents and Settings folder, to no avail.

Is there anything that can be done?


Posted by Andrea DeMarco on February 24, 2009 at 04:00 PM PST #

Hi Winston,
I am using NB6.1 ,By changing the static text to text field in table layout we can edit the data in to jsf table.But how
can we update the whole columns we edited, Into database.

Posted by chandu on October 27, 2009 at 09:28 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

« April 2014