Class TableAdapter

java.lang.Object
com.groiss.gui.table.TableAdapter
All Implemented Interfaces:
Table
Direct Known Subclasses:
ConfiguredTable

public class TableAdapter extends Object implements Table
Adapter class for the table interface. It is recommended to make subclasses of this class or use it directly instead of implementing the table interface with another class.
The class has several protected fields that can be set by subclasses for defining the behavior of the table.
  • Field Details

    • request

      protected HttpServletRequest request
      The HTTP request is set in the init method
    • model

      protected TableModel model
    • id

      protected String id
    • title

      protected String title
    • resource

      protected Resource resource
    • sortable

      protected boolean sortable
    • sortColumn

      protected int sortColumn
    • asc

      protected boolean asc
    • selection

      protected int selection
    • selected

      protected List<String> selected
    • fieldname

      protected String fieldname
    • oidOnly

      protected boolean oidOnly
    • editUrl

      protected String editUrl
    • editTarget

      protected String editTarget
    • editTargetProps

      protected String editTargetProps
    • toolbarActions

      protected String toolbarActions
    • toolbarTarget

      protected String toolbarTarget
    • tableTarget

      protected String tableTarget
    • verticalToolbar

      protected boolean verticalToolbar
    • toolbarIcons

      protected boolean toolbarIcons
    • toolbarShape

      protected Table.ToolbarShape toolbarShape
    • toolbarSize

      protected Integer toolbarSize
    • defaultAction

      protected String defaultAction
    • showCounter

      protected boolean showCounter
    • columns

      protected List<ColumnDescription> columns
    • useFilter

      protected boolean useFilter
    • useColumnPicker

      protected boolean useColumnPicker
    • usePaging

      protected boolean usePaging
    • searchString

      protected String searchString
    • pageString

      protected String pageString
    • page

      protected Page page
    • helpctx

      protected String helpctx
  • Constructor Details

    • TableAdapter

      public TableAdapter()
    • TableAdapter

      public TableAdapter(TableModel m, String id)
  • Method Details

    • init

      public void init(HttpServletRequest req)
      Init the tablemodel (determine data to be displayed).
      Specified by:
      init in interface Table
    • setSearchString

      public void setSearchString(String searchString)
      Sets the search string for that table which may be used for filtering the table content
      Specified by:
      setSearchString in interface Table
      Parameters:
      searchString - a string for filtering or null if no search string is defined
    • getTableSize

      public int getTableSize()
      Determines the tablesize of the tablemodel without reading all the objects.
      Specified by:
      getTableSize in interface Table
      Returns:
      int representing the actual tablesize
    • getTableModel

      public TableModel getTableModel()
      Builds the final tablemodel containing all data displayed in the table.
      Specified by:
      getTableModel in interface Table
      Returns:
      TableModel containing all the data
    • getTitle

      public Object getTitle()
      Return a string or Component for table title
      Specified by:
      getTitle in interface Table
    • getId

      public String getId()
      Returns the id of this table
      Specified by:
      getId in interface Table
    • getPage

      public Page getPage()
      Define the page the table uses. Has to return a new, empty page on each call.
      Specified by:
      getPage in interface Table
    • setPage

      public void setPage(String pageString)
    • setPage

      public void setPage(Page page)
    • lineStyle

      public String lineStyle(int i, String style)
      Use this method for defining a row specific css-class.
      Specified by:
      lineStyle in interface Table
      Parameters:
      i - the row index
      style - the css class that is set by the table renderer
      Returns:
      a css class
    • isSortable

      public boolean isSortable()
      Is the table sortable.
      Specified by:
      isSortable in interface Table
    • sortAscending

      public boolean sortAscending()
      Is the table sorted ascending.
      Specified by:
      sortAscending in interface Table
    • getSortColumn

      public int getSortColumn()
      Return the sort column.
      Specified by:
      getSortColumn in interface Table
    • getSelectionMode

      public int getSelectionMode()
      Return the mode for selection.
      Specified by:
      getSelectionMode in interface Table
      Returns:
      one of SELECTION_NONE, SELECTION_LINK, SELECTION_SINGLE, SELECTION_MULTIPLE, SELECTION_ROW_SINGLE, SELECTION_ROW_MULTIPLE
    • getFieldName

      public String getFieldName()
      Return the name of the checkbox or radio buttons
      Specified by:
      getFieldName in interface Table
    • oidOnly

      public boolean oidOnly()
      If true the value of the checkbox or radio button contains only the oid, otherwise it contains classname:oid
      Specified by:
      oidOnly in interface Table
    • getEditUrl

      public String getEditUrl()
      Returns an url used as link for toolbar functions
      Specified by:
      getEditUrl in interface Table
    • getEditTarget

      public String getEditTarget()
      The default target for toolbar functions
      Specified by:
      getEditTarget in interface Table
    • getEditTargetProps

      public String getEditTargetProps()
      Return the window properties for the edit target
      Specified by:
      getEditTargetProps in interface Table
    • getToolbarActions

      public String getToolbarActions()
      Return a comma separated list of action ids for the toolbar.
      Specified by:
      getToolbarActions in interface Table
    • getTableFrameName

      public String getTableFrameName()
      Returns the name of the frame where the table resides.
      Specified by:
      getTableFrameName in interface Table
    • getToolbarFrameName

      public String getToolbarFrameName()
      Returns the name of the frame where the toolbar resides.
      Specified by:
      getToolbarFrameName in interface Table
    • hasVerticalToolbar

      public boolean hasVerticalToolbar()
      Returns true if the toolbar is vertical, false for horizontal.
      Specified by:
      hasVerticalToolbar in interface Table
    • showToolbarIcons

      @Deprecated public boolean showToolbarIcons()
      Deprecated.
      Returns true if the toolbar shows the icons, false for text toolbar.
      Specified by:
      showToolbarIcons in interface Table
    • getToolbarShape

      public Table.ToolbarShape getToolbarShape()
      Description copied from interface: Table
      Returns the desired mode of the toolbar.
      Specified by:
      getToolbarShape in interface Table
    • setToolbarSize

      public void setToolbarSize(int toolbarSize)
      Parameters:
      toolbarSize - the toolbarSize to set
    • getToolbarSize

      public Integer getToolbarSize()
      Specified by:
      getToolbarSize in interface Table
    • setToolbarShape

      public void setToolbarShape(String s)
    • getDefaultAction

      public String getDefaultAction()
      Returns the action that is executed on doubleclick on a row. See Table.getToolbarActions() for a description of allowed values
      Specified by:
      getDefaultAction in interface Table
    • useFilter

      public boolean useFilter()
      Returns true if column filters are enabled.
      Specified by:
      useFilter in interface Table
    • useColumnPicker

      public boolean useColumnPicker()
      Returns true if column picker should be shown.
      Specified by:
      useColumnPicker in interface Table
    • usePaging

      public boolean usePaging()
      Returns true if paging is enabled.
      Specified by:
      usePaging in interface Table
    • showCounter

      public boolean showCounter()
      Returns true if a counter is shown below the table.
      Specified by:
      showCounter in interface Table
    • getColumns

      public List<ColumnDescription> getColumns()
      Return a list of column descriptions.
      Specified by:
      getColumns in interface Table
    • getFilterId

      public String getFilterId()
      Description copied from interface: Table
      Returns the id that is used when column filters are stored. Normally this will be the id of the table, but if it is desired to use filters for several tables, another id can be defined.
      Specified by:
      getFilterId in interface Table
    • setSortable

      public TableAdapter setSortable(boolean isSortable, int col, boolean asc)
      Set the sort properties.
      Parameters:
      isSortable - true if sortable.
      col - the sort column
      asc - the sort order (true = ascending)
      Returns:
      the TableAdapter
    • setSelection

      public TableAdapter setSelection(int selection, String fieldname, boolean oidOnly, List<String> selected)
      Set the selection properties.
      Parameters:
      selection - see Table.getSelectionMode() for values
      fieldname - see Table.getFieldName()
      oidOnly - see Table.oidOnly()
      selected - a list of already selected values
      Returns:
      the TableAdapter
    • setEditProps

      public TableAdapter setEditProps(String editUrl, String editTarget, String winProps, String toolbarActions, String toolbarTarget)
      Set the edit properties.
      Parameters:
      editUrl -
      editTarget -
      winProps -
      toolbarActions -
      toolbarTarget -
      Returns:
      the TableAdapter
    • setHelpContext

      public TableAdapter setHelpContext(String ctx)
      Set the help context for online help.
      Parameters:
      ctx -
      Returns:
      the TableAdapter
    • showCounter

      public TableAdapter showCounter(boolean show)
      Define whether a counter should be shown.
      Parameters:
      show - true if a counter is wanted.
    • setTitle

      public TableAdapter setTitle(String title)
      Set the title of the table.
    • setColumns

      public TableAdapter setColumns(List<ColumnDescription> cols, boolean useFilter, boolean useColumnPicker)
      Set the column properties.
      Parameters:
      cols -
      useFilter -
      useColumnPicker -
    • setDefaultAction

      public TableAdapter setDefaultAction(String action)
      Set the default action.
    • getSelectedItems

      public List<String> getSelectedItems()
      Specified by:
      getSelectedItems in interface Table
    • getHelpContext

      public String getHelpContext()
      Returns the context for online-help
      Specified by:
      getHelpContext in interface Table
    • getPagesize

      public int getPagesize()
      The default implementation reads the table.pagesize property as default and the user property avw.table.pagesize.
      Specified by:
      getPagesize in interface Table
    • parseSelection

      public void parseSelection(String select, int defaultValue)