Class Table
java.lang.Object
javax.servlet.jsp.tagext.TagSupport
net.sf.basedb.clients.web.taglib.StylableTag
net.sf.basedb.clients.web.taglib.table.Table
- All Implemented Interfaces:
Serializable
,DynamicAttributes
,IterationTag
,JspTag
,Tag
,DynamicActionAttributes
public class Table extends StylableTag
This is the main tag for the table. It must be located inside
a
<base:page>
tag.
Syntax:
<tbl:table id=... clazz=.... style=... title=... sortby=... direction=ASC|DESC columns=... filterrows=... sc=... item=... subcontext=... action=... stickyheaders=... dragcolumns=true|false|null >
Attribute | Default value | Required | Description |
id | - | yes |
The ID of the table. The value of this attribute
goes directly into the standard HTML id attribute.
This means that if you need a reference to the table object in your own
JavaScript code, you may for example use the following code:
table = document.getElementById('<id>'); |
clazz | - | no |
The value if this attribute goes directly into the standard HTML
class attribute. This allows you to apply different styles
to different tables.
|
style | - | no |
The value if this attribute goes directly into the standard HTML
style attribute. This allows you to apply different styles
to different tables.
|
title | - | no |
An optional title that will be displayed in <h3>
format directly above the table.
|
sortby | - | no |
Matches the property attribute on a <tbl:columdef> tag.
This column will then be marked with an upwards or downward pointer
according to the direction attribute.
|
direction | asc | no |
The value should be either asc or desc to
indicate if the rows are sorted in ascending or descending order.
Other values are interpreted as asc .
|
columns | - | no |
A comma-separatd list of column ID:s. Only columns with an ID in the list
will be shown in the table. The special value all shows all
columns. Individual columns may override this setting by
specifying always or never instead of the default
auto value in their show attribute.
|
filterrows | 1 | no | Number of filter rows that should be displayed in the table. |
action | name of current page | no | The action property of the <form> tag. |
sc | - | no | The current SessionControl object. Used by some child taglibs for generating context sensitive information. |
item | - | no | The current Item object. Used by some child taglibs for generating context sensitive information (ie. PresetSelector). |
subcontext | "" (empty string) | no | The name of the current subcontext. Used by some child taglibs for generating context sensitive information (ie. PresetSelector). |
stickyheaders | - | no | Enable sticky headers and optionally set the name of a sticky column. Do not set this attribute if the table should not have sticky headers. |
dragcolumns | null | no | If set, controls if columns can be re-ordered by dragging them in the GUI. If null, the feature is enabled only if the "action" and "item" attributes are not null. |
The <tbl:table>
may contain the following subtags:
<tbl:toolbar>
: Creates a toolbar with buttons<tbl:navigator>
: Creates the page navigator<tbl:data>
: Begins the data section
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description private String
action
private boolean
allVisible
"all" was specified for the columns attribute.private Map<String,String>
columnContent
private Map<String,String>
columnFilter
private Map<String,Formatter<?>>
columnFormatter
private String
columns
Which columns that should be visible and their orderprivate Map<String,String>
columnSubtitle
private Set<String>
definedColumns
The ID of all defined columnsprivate Boolean
dragColumns
private int
evenodd
Keep track of which class to use for the next row.private List<ListColumnAction>
extensionColumns
private Set<String>
hiddenFilteredColumns
private StringBuilder
hiddenForm
private Item
itemType
private org.json.simple.JSONArray
jsonColumnDefs
private int
numFilteredColumns
private int
numFilterRows
Number of filter rows in the table.private int
numHeaderColumns
private Page
page
The parent <base:page> tag.private static String[]
rowclass
The class names for even and odd row respectively.private SessionControl
sc
private static long
serialVersionUID
private String
sortby
The column to sort by.private Map<String,ItemContext.SortDirection>
sortColumns
private ItemContext.SortDirection
sortDirection
ASC or DESCprivate String
stickyCol
The id of a column that is "sticky".private boolean
stickyHeaders
If sticky headers is enabled or not.private String
subcontext
private String
title
An optional title of the table.private Set<String>
visibleColumns
The ID of all visible columns, sorted by the order they should appear.Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
-
Constructor Summary
Constructors Constructor Description Table()
-
Method Summary
Modifier and Type Method Description (package private) void
addColumnDef(ColumnDef cd, ListColumnAction extensionColumn)
(package private) void
addFilteredColumn(String columnId, String filterProperty, boolean visible)
(package private) void
addHidden(String name, String value)
(package private) boolean
allowColumnDrag()
Can header columns be dragged for re-ordering?int
doEndTag()
int
doStartTag()
(package private) void
endColumnDefinitions()
(package private) void
endColumnFilters()
String
getAction()
(package private) Map<String,String>
getColumnContent()
String
getColumns()
(package private) Map<String,String>
getColumnSubtitles()
ItemContext.SortDirection
getDirection()
(package private) String
getDirectionImage(ItemContext.SortDirection direction)
Get sort direction <img> element for the given direction.Boolean
getDragcolumns()
(package private) List<ListColumnAction>
getExtensionColumns()
int
getFilterrows()
(package private) Formatter<?>
getFormatter(String columnId)
(package private) Set<String>
getHiddenFilteredColumns()
Item
getItem()
(package private) String
getNextRowClass()
(package private) int
getNumFilteredColumns()
(package private) Page
getPage()
SessionControl
getSc()
String
getSortby()
(package private) ItemContext.SortDirection
getSortDirection(String colum)
Get the sort direction on the given column.String
getStickyCol()
String
getSubcontext()
String
getTitle()
(package private) Set<String>
getVisibleColumns()
boolean
hasStickyHeaders()
(package private) boolean
isColumnSticky(String columnId)
(package private) boolean
isColumnVisible(String columnId)
(package private) int
numHeaderColumns()
(package private) int
numVisibleColumns()
void
setAction(String action)
(package private) void
setColumnContent(String columnId, String content)
(package private) void
setColumnFilter(String columnId, int row, String filterHtml)
void
setColumns(String columns)
void
setDirection(String direction)
void
setDirection(ItemContext.SortDirection direction)
void
setDragcolumns(Boolean dragColumns)
void
setFilterrows(int filterRows)
void
setItem(Item itemType)
(package private) void
setNumColumns(int numColumns)
void
setSc(SessionControl sc)
void
setSortby(String sortby)
void
setStickyheaders(String stickyCol)
void
setSubcontext(String subcontext)
void
setTitle(String title)
(package private) int
writeColumnFilters(int row)
(package private) int
writeColumns()
(package private) int
writeColumnSubtitles(StringBuilder sb)
Methods inherited from class net.sf.basedb.clients.web.taglib.StylableTag
addDynamicAttributes, addIdAndStyles, getClazz, getDynamicActionAttributes, getDynamicAttribute, getFullClass, getIdPrefix, getStyle, getSubclass, initDefaultAttributes, setClazz, setDynamicAttribute, setMoreDynamicAttributes, setPageContext, setStyle, setSubclass
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setParent, setValue
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
- Constant Field Values
-
page
The parent <base:page> tag. -
title
An optional title of the table. -
sortby
The column to sort by. Should match the sort attribute on the column tag. -
sortColumns
-
action
-
sc
-
itemType
-
subcontext
-
sortDirection
ASC or DESC -
columns
Which columns that should be visible and their order -
stickyHeaders
private boolean stickyHeadersIf sticky headers is enabled or not. -
stickyCol
The id of a column that is "sticky". -
numFilterRows
private int numFilterRowsNumber of filter rows in the table. -
evenodd
private int evenoddKeep track of which class to use for the next row. -
rowclass
The class names for even and odd row respectively. -
allVisible
private boolean allVisible"all" was specified for the columns attribute. -
visibleColumns
The ID of all visible columns, sorted by the order they should appear. -
definedColumns
The ID of all defined columns -
columnContent
-
columnFilter
-
columnSubtitle
-
columnFormatter
-
extensionColumns
-
jsonColumnDefs
private org.json.simple.JSONArray jsonColumnDefs -
numHeaderColumns
private int numHeaderColumns -
numFilteredColumns
private int numFilteredColumns -
dragColumns
-
-
Constructor Details
-
Table
public Table()
-
-
Method Details
-
setTitle
-
getTitle
-
setColumns
-
getColumns
-
setStickyheaders
- Since:
- 3.18.1
-
hasStickyHeaders
public boolean hasStickyHeaders()- Since:
- 3.18.1
-
getStickyCol
- Since:
- 3.18.1
-
setDragcolumns
- Since:
- 3.8
-
getDragcolumns
-
setFilterrows
public void setFilterrows(int filterRows)- Since:
- 3.5
-
getFilterrows
public int getFilterrows() -
setSortby
-
getSortby
-
setAction
-
getAction
-
setSc
-
getSc
-
setItem
-
getItem
-
setSubcontext
-
getSubcontext
-
setDirection
-
setDirection
-
getDirection
-
getPage
Page getPage() -
addColumnDef
-
endColumnDefinitions
void endColumnDefinitions() -
isColumnVisible
-
getVisibleColumns
-
isColumnSticky
-
getFormatter
-
setColumnContent
-
getColumnContent
-
getColumnSubtitles
-
setColumnFilter
-
addFilteredColumn
-
getHiddenFilteredColumns
-
writeColumns
- Throws:
Exception
-
writeColumnFilters
- Throws:
Exception
-
writeColumnSubtitles
-
endColumnFilters
void endColumnFilters() -
getSortDirection
Get the sort direction on the given column. If it is not used for sorting, null is returned.- Since:
- 3.3
-
getDirectionImage
Get sort direction <img> element for the given direction. Return an empty string if direction = null.- Since:
- 3.3
-
getNextRowClass
String getNextRowClass() -
addHidden
-
numVisibleColumns
int numVisibleColumns() -
getNumFilteredColumns
int getNumFilteredColumns() -
setNumColumns
void setNumColumns(int numColumns) -
numHeaderColumns
int numHeaderColumns() -
getExtensionColumns
List<ListColumnAction> getExtensionColumns() -
allowColumnDrag
boolean allowColumnDrag()Can header columns be dragged for re-ordering? IfsetDragcolumns(Boolean)
has been set we use that value, otherwise we only allow it if the "action" attribute has been set.- Since:
- 3.8
-
doStartTag
- Specified by:
doStartTag
in interfaceTag
- Overrides:
doStartTag
in classTagSupport
- Throws:
JspException
-
doEndTag
- Specified by:
doEndTag
in interfaceTag
- Overrides:
doEndTag
in classTagSupport
- Throws:
JspException
-