1. Tapestry
  2. TAPESTRY-933

Add getRowCount() to ITableModel interface


    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.0.1
    • Fix Version/s: 4.1.2
    • Component/s: Contrib
    • Labels:
    • Environment:


      All classes that implement ITableModel already have a getRowCount() method. It would be useful to call this method from subclasses of AbstractTableViewComponent, which can access the underlying ITableModel through ITableModelSource.getTableModelSource().getTableModel().

      My specific use case is a "PageInfo" component included in a custom Table component that displays something along the lines of "Viewing items x - x of xx." Because any combination of "source" and "columns" parameters to a TableView component results in an AbstractTableModel (which defines getRowCount() as protected), I currently cast getTableModelSource().getTableModel() to an AbstractTableModel and use reflection to call getRowCount(). This works for the range of data sources I currently use with TableView, but is obviously an ugly hack.

      Adding getRowCount() to ITableModel would require the following additional changes:
      1. Make getRowCount() in AbstractTableModel public.
      2. Mage getRowCount() in BasicTableModelWrap public.
      3. Make getRowCount() in SqlTableModel public.

      I am aware that repeated calls to getRowCount() could create performance issues, especially for database-backed table models such as IBasicTableModel. However, caching the row count can be handled easily in an IBasicTableModel class and is outside the scope of the Table components anyway.

      If a change to the ITableModel interface is considered too radical in the near term, a workaround would be to change the access modifier of AbstractTableModel.getRowCount() from protected to public. This would provide easy access to getRowCount in most cases.


        Ryan Holmes created issue -
        Ryan Holmes added a comment -

        Is there any reason not to make this change? It would be great to get some feedback...

        Ryan Holmes added a comment - Is there any reason not to make this change? It would be great to get some feedback...
        Jesse Kuhnert made changes -
        Field Original Value New Value
        Fix Version/s 4.1.2 [ 12312202 ]
        Jesse Kuhnert made changes -
        Resolution Fixed [ 1 ]
        Assignee Jesse Kuhnert [ jkuhnert ]
        Status Open [ 1 ] Resolved [ 5 ]
        Mark Thomas made changes -
        Workflow jira [ 12361797 ] Default workflow, editable Closed status [ 12568167 ]
        Mark Thomas made changes -
        Workflow Default workflow, editable Closed status [ 12568167 ] jira [ 12591251 ]


          • Assignee:
            Jesse Kuhnert
            Ryan Holmes
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created: