SPT Core API

com.sptci.echo2.table
Class TableNavigation<D>

java.lang.Object
  extended by nextapp.echo2.app.Component
      extended by nextapp.echo2.app.Row
          extended by com.sptci.echo2.table.TableNavigation<D>
Type Parameters:
D - The class of the model object displayed in the associated table.
All Implemented Interfaces:
Serializable, RenderIdSupport

public class TableNavigation<D>
extends Row

A navigation component for displaying paging controls for a Table.

The following shows sample localisation of this class:

   com.sptci.echo2.table.TableNavigation.resultsPerPage.options 10,25,50,100
   com.sptci.echo2.table.TableNavigation.page.label         Page
   com.sptci.echo2.table.TableNavigation.pageCount.label    of
   com.sptci.echo2.table.TableNavigation.FirstPage.text     First
   com.sptci.echo2.table.TableNavigation.FirstPage.tooltip  Go to first page
 

© Copyright 2007 Sans Pareil Technologies, Inc.

Version:
$Id: TableNavigation.java 4553 2008-12-24 10:34:16Z rakesh $
Author:
Rakesh Vidyadharan 2007-10-05
See Also:
Serialized Form

Nested Class Summary
protected  class TableNavigation.FirstListener
          The ActionListener for events triggered by the button to go to the first page.
protected  class TableNavigation.LastListener
          The ActionListener used to control the navigation to the last available page.
protected  class TableNavigation.NextListener
          The ActionListener for the control used to navigation to the next page of data.
protected  class TableNavigation.PageSelectListener
          The ActionListener for events fired by the page select component.
protected  class TableNavigation.PreviousListener
          The ActionListener for the control used to navigate to the previous page.
protected  class TableNavigation.RowsPerPageListener
          The ActionListener used to control the number or rows displayed per page.
 
Field Summary
static int MINIMUM_PAGE_SIZE
          The minimum number of rows to hold in a page.
 
Fields inherited from class nextapp.echo2.app.Row
PROPERTY_ALIGNMENT, PROPERTY_BORDER, PROPERTY_CELL_SPACING, PROPERTY_INSETS
 
Fields inherited from class nextapp.echo2.app.Component
CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FOCUS_TRAVERSAL_INDEX_CHANGED_PROPERTY, FOCUS_TRAVERSAL_PARTICIPANT_CHANGED_PROPERTY, LAYOUT_DIRECTION_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, PROPERTY_BACKGROUND, PROPERTY_FONT, PROPERTY_FOREGROUND, PROPERTY_LAYOUT_DATA, STYLE_CHANGED_PROPERTY, STYLE_NAME_CHANGED_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
TableNavigation(PageableTableModel model)
          Create a new instance of the navigation component using the specified table component.
 
Method Summary
protected  void doLayout()
           
protected  Button getButton(String name)
          Create the button used to control navigation among the pages.
protected  ActionListener getListener(String name)
          Return the ActionListener to use for the specified name.
 PageableTableModel<D> getModel()
          Return the model backing this navigation component.
protected  Label getPageCountLabel()
          Create the label used to display the page count indicator to user.
protected  Label getPageLabel()
          Create the label used to display the page indicator to user.
protected  SelectField getPageSelect()
          Create a SelectField that displays all the pages of data that are viewable by the user.
protected  Label getResultsPerPageLabel()
          Create the label used to display the component used to control the number of items displayed on a page.
protected  SelectField getResultsPerPageSelect()
          Create a SelectField that displays the options for displaying number of rows on a page.
 void init()
          Re-initialises all the controls for this component.
protected  void reset()
          Reset the display of this component.
 void setCurrentPage(int page)
          Set the page that is to be displayed.
protected  void setDisplayedPage(int page)
          Set the page that is to be displayed.
 
Methods inherited from class nextapp.echo2.app.Row
getAlignment, getBorder, getCellSpacing, getInsets, setAlignment, setBorder, setCellSpacing, setInsets
 
Methods inherited from class nextapp.echo2.app.Component
add, add, addPropertyChangeListener, addPropertyChangeListener, dispose, firePropertyChange, getApplicationInstance, getBackground, getComponent, getComponent, getComponentCount, getComponents, getEventListenerList, getFocusTraversalIndex, getFont, getForeground, getId, getIndexedProperty, getLayoutData, getLayoutDirection, getLocale, getParent, getProperty, getRenderId, getRenderIndexedProperty, getRenderIndexedProperty, getRenderLayoutDirection, getRenderLocale, getRenderProperty, getRenderProperty, getStyle, getStyleName, getVisibleComponent, getVisibleComponentCount, getVisibleComponents, hasEventListenerList, indexOf, isAncestorOf, isEnabled, isFocusTraversalParticipant, isRegistered, isRenderEnabled, isRenderVisible, isValidChild, isValidParent, isVisible, processInput, remove, remove, removeAll, removePropertyChangeListener, removePropertyChangeListener, setBackground, setEnabled, setFocusTraversalIndex, setFocusTraversalParticipant, setFont, setForeground, setId, setIndexedProperty, setLayoutData, setLayoutDirection, setLocale, setProperty, setRenderId, setStyle, setStyleName, setVisible, validate, verifyInput, visibleIndexOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINIMUM_PAGE_SIZE

public static final int MINIMUM_PAGE_SIZE
The minimum number of rows to hold in a page.

Constructor Detail

TableNavigation

public TableNavigation(PageableTableModel model)
Create a new instance of the navigation component using the specified table component.

Parameters:
model - The model that is used as the backing (model) for this navigation component.
Method Detail

init

public void init()
Re-initialises all the controls for this component.

Overrides:
init in class Component
See Also:
Component.init(), reset()

doLayout

protected void doLayout()
See Also:
getButton(java.lang.String), getResultsPerPageSelect(), getPageLabel(), getPageSelect(), getPageCountLabel()

reset

protected void reset()
Reset the display of this component. Removes and readds all the controls.


getModel

public PageableTableModel<D> getModel()
Return the model backing this navigation component.

Returns:
The model used to back the navigation component.

setCurrentPage

public void setCurrentPage(int page)
Set the page that is to be displayed. Updates the model to display the specified page of data.

Parameters:
page - The number of the page that is to be displayed.
See Also:
setDisplayedPage(int)

setDisplayedPage

protected void setDisplayedPage(int page)
Set the page that is to be displayed. Does not update the model. Updates only the value selected in pageSelect.

Parameters:
page - The number of the page that is to be displayed.
Since:
2007-11-14

getPageSelect

protected SelectField getPageSelect()
Create a SelectField that displays all the pages of data that are viewable by the user.

Returns:
The select field initialised with all the pages available.

getPageLabel

protected Label getPageLabel()
Create the label used to display the page indicator to user. This value is localised through the com.sptci.echo2.table.TableNavigation.page.label key.

Returns:
The label component for the page indicator.

getPageCountLabel

protected Label getPageCountLabel()
Create the label used to display the page count indicator to user. This value is localised through the com.sptci.echo2.table.TableNavigation.pageCount.label key.

Returns:
The label component for the page count.

getButton

protected Button getButton(String name)
Create the button used to control navigation among the pages. The value is localised through the com.sptci.echo2.table.TableNavigation.<name>Page.text com.sptci.echo2.table.TableNavigation.<name>Page.tooltip keys.

Parameters:
name - The name to use to identify the button being created.
Returns:
The button component for navigation.
See Also:
getListener(java.lang.String)

getResultsPerPageLabel

protected Label getResultsPerPageLabel()
Create the label used to display the component used to control the number of items displayed on a page. This value is localised through the com.sptci.echo2.table.TableNavigation.resultsPerPage.label key.

Returns:
The label component for the results per page.

getResultsPerPageSelect

protected SelectField getResultsPerPageSelect()
Create a SelectField that displays the options for displaying number of rows on a page.

Returns:
The select field with the options for displaying number of rows on a page.

getListener

protected ActionListener getListener(String name)
                              throws RuntimeException
Return the ActionListener to use for the specified name. The listeners are used to navigate between the pages.

Parameters:
name - The name to use to create the listener.
Returns:
The action listener for the named component.
Throws:
RuntimeException - If errors are encountered while fetching or initialising the Constructor for the action listener via reflection.

SPT Core API