A rather clean approach would have been EJB returns a List, Bind the List to Table Component . Thats-it every thing has to work. There are two intresting problems to solve
1) Sorting :- The Table component does its own sorting. It does not use database sorting capabilities nor ejb facilities. Solution is writing TableSorter and bind it to the TableComponent.
2) Paging :- The dataprovider performs the job of paging. Dataprovider interface provides
getRowKeys(int count, RowKey afterRow). The strait forward approach will be overwrite these methods in the custom dataprovider. But intrestingly the TableComponent has a bug. It always call this method with afterRow=null. As a result we cannot use inbuilt paging features of the Table Component. Final solution is to write addtional methods in dataprovier to handle paging and call these methods from buttons/links on the webpage.
Using Standard table component : Supports paging ,Does not support sorting, Does not support themes.
Not using Dataprovider : Jsf page still works with out dataprovider. We loose on visual binding of fields with the Table component. The TableLayout screen will not work.
Scope of Dataprovider and Table sorter : Dataprovider can be move to page scope by moving the maxresults and starPosition variables to session. Table Sorter cannot be moved out of session scope.
NetBeans should some how automatically generate dataprovider, delegate paging and sorting to ejb layer. Table componet has to be- smarter :)