Cappuccino : TableView, datasource, pagination

Posted: October 2, 2008 in Apple, IT/Dev

Among CPView available for now in Cappuccino we find : CPClipView, CPCollectionView, CPControl, CPFlashView (!), CPProgressIndicator, CPScrollView, CPShadowView, CPTabView, NSCustomView, NSView, _CPWindowView. There isn’t yeat any equivalent to NSTableView, NSOutlineView or NSBrowser, but the Cappuccino team is working on the implementation of a CPTableView :

The CPTableView is still under development, it’s already in the repository if you want to have a look. After this is finished i think the cappuccino team or someone else will pickup the work on CPBrowser. 

It seems hard work due to these components complexity :

CPTableView : needs all of NSTableView and supporting classes. We’re not going to be using NSCell’s though, so we’ll also need to make some decisions on exactly what to do here, at least when straight up NSView replacement isn’t enough. 

However that team still managed to write about 20 000 lines of code for Cappuccino’s AppKit and FoundationKit.
Meanwhile they advice using a CPCollectionView (and CPCollectionViewItem), but then we have no column headers no rearrange feature (no column move nor resizing).

Once these hierarchical models display components are available, the Nib2Nic team will be able to manage the appropriate conversion, with the important (and impacting) difference that CPTableView shouldn’t rely on Cell classes.

Usually enterprise applications rely on paginated table components in order to limit the requested data size (in a cursor way). With Cocoa TableView are included in a ScrollView, and only visible rows (at the current position, that is the current position of the vertical scroller) are loaded (requested to the datasource object). Then while scrolling, the datasource provides the additional rows only, never the whole table data (except when they all fit in the visible area).
Cocoa indeed dispatchs the rows on multiple pages when preparing the component for printing.

When the CPTableView will be available in Cappuccino, we will just need to implement that simple datasource object’s method : (id)tableView: (CPTableView *)aTableView objectValueForTableColumn: (CPTableColumn*)aTableColumn row: (int)rowIndex.
It will typically trigger a JSONP request to the server in order to retreive values for that cell. We will probably prefer maintaining a cache to avoid making a database request for only such a cell. In fact in that case the TableView model with scrollable view won’t look appropriate (a tableView: objectsArrayForTableColumn: page: method would be better).
Moreover, if we want to manage sorting (with ascending or descending order) – what is easily done in Cocoa -, we won’t be able to consider the columns separately, and the datasource method will have to look like this (will return a cells values matrix) : tableView: objectsMatrix: forPage: sortingColumn: ascendingOrder:.

Update: We can now use the new CP2JavaWSTableViewDelegate component as CPTableView’s datasource for automatic cached access while scrolling in the table view. It allows fast browsing of tables with thousands of elements without stressing the application server nor database server, and without requriring any pagination !
No GWT component, JSF or other provides that feature yet : they all use pagination (data splitted into multiple pages), that is less practical, less intuitive and slower to reach the desired element (if you have thousands of elements you can’t have all pages number displayed, so you have to use many times forward/fast forward buttons).


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s