Friday, November 17, 2006

Sorting and Paging with EJB Alternatives

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 getRowCount(),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.


Other options

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.

Desired Solution

NetBeans should some how automatically generate dataprovider, delegate paging and sorting to ejb layer. Table componet has to be- smarter :)

1 comment:

Phuket web design said...

nice information i am going to keep reading all the time.
phuket web design