Aug 11, 2008

Netbeans Visual Web Tables with thousands of records

Maybe you have noticed that the table component in Netbeans visual
web tends to become quite slow if it has to deal with a huge amount of
records (e.g. coming from a database).
This is true even if pagination is used.

The reason is that the typical dataproviders (e.g. ObjectArrayDataProvider) on the server side require a complete fetch of all data from the database.
Based on this data they analyze the amount of records which in turn is used to operate the augmented table header and the pagination controls.
Thus the application does not only become slow (because of the sql operations) but also consumes a large amount of memory.

To overcome this problem I have created a new dataprovider called ObjectControllerDataprovider.
Like all the other dataprovider this class can directly be used in the table layout of the visual table component.
This ObjectControllerDataprovider is in turn connected an ObjectController.
In more detail the ObjectControllerDataprovider is connected to a class that is to be written manually which extends the abstract ObjectController class.
The manual written class finally contains the functionality to efficiently retrieve small pages from a database utilizing a caching window concept.

You can download a working Netbeans 6.1 example project using the new dataprovider from the following link: http://sites.google.com/site/owahlen/Home/ObjectControllerTest.tar.gz

1 comment:

Unknown said...

Hi,

Thanks for this great piece of code. Saved me a lot of work.
Hope you're still out there.

This is working nicely in my project except for column sorting.

Since, I limit the dataset size in my SQL statement to the windowsize as specified in ObjectController... when doing a column sorting... calls to the getElements in my Object Controller never stopped (the tableprovider trying to catch up all the data for proper sorting).

Do you have an easy way to implement easy sorting?
Basically I would need to have access to the sort criteria from within the "getElements" method of my Object controller so I can apply the criteria to the SQL statement.

Make sense?

Thank you again,
N