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 >
Tag attributes 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 thedirection
attribute.direction asc no The value should be either asc
ordesc
to indicate if the rows are sorted in ascending or descending order. Other values are interpreted asasc
.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 specifyingalways
ornever
instead of the defaultauto
value in theirshow
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 List<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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addColumnDef(ColumnDef cd, ListColumnAction extensionColumn)
(package private) void
addFilteredColumn(String columnId, 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) List<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 Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
page
private Page page
The parent <base:page> tag.
-
title
private String title
An optional title of the table.
-
sortby
private String sortby
The column to sort by. Should match the sort attribute on the column tag.
-
sortColumns
private Map<String,ItemContext.SortDirection> sortColumns
-
action
private String action
-
sc
private transient SessionControl sc
-
itemType
private Item itemType
-
subcontext
private String subcontext
-
sortDirection
private ItemContext.SortDirection sortDirection
ASC or DESC
-
columns
private String columns
Which columns that should be visible and their order
-
stickyHeaders
private boolean stickyHeaders
If sticky headers is enabled or not.
-
stickyCol
private String stickyCol
The id of a column that is "sticky".
-
numFilterRows
private int numFilterRows
Number of filter rows in the table.
-
hiddenForm
private StringBuilder hiddenForm
-
evenodd
private int evenodd
Keep track of which class to use for the next row.
-
rowclass
private static final String[] rowclass
The class names for even and odd row respectively.
-
allVisible
private boolean allVisible
"all" was specified for the columns attribute.
-
visibleColumns
private Set<String> visibleColumns
The ID of all visible columns, sorted by the order they should appear.
-
extensionColumns
private List<ListColumnAction> extensionColumns
-
jsonColumnDefs
private org.json.simple.JSONArray jsonColumnDefs
-
numHeaderColumns
private int numHeaderColumns
-
numFilteredColumns
private int numFilteredColumns
-
dragColumns
private Boolean dragColumns
-
-
Method Detail
-
setTitle
public void setTitle(String title)
-
getTitle
public String getTitle()
-
setColumns
public void setColumns(String columns)
-
getColumns
public String getColumns()
-
setStickyheaders
public void setStickyheaders(String stickyCol)
- Since:
- 3.18.1
-
hasStickyHeaders
public boolean hasStickyHeaders()
- Since:
- 3.18.1
-
getStickyCol
public String getStickyCol()
- Since:
- 3.18.1
-
setDragcolumns
public void setDragcolumns(Boolean dragColumns)
- Since:
- 3.8
-
getDragcolumns
public Boolean getDragcolumns()
-
setFilterrows
public void setFilterrows(int filterRows)
- Since:
- 3.5
-
getFilterrows
public int getFilterrows()
-
setSortby
public void setSortby(String sortby)
-
getSortby
public String getSortby()
-
setAction
public void setAction(String action)
-
getAction
public String getAction()
-
setSc
public void setSc(SessionControl sc)
-
getSc
public SessionControl getSc()
-
setItem
public void setItem(Item itemType)
-
getItem
public Item getItem()
-
setSubcontext
public void setSubcontext(String subcontext)
-
getSubcontext
public String getSubcontext()
-
setDirection
public void setDirection(String direction)
-
setDirection
public void setDirection(ItemContext.SortDirection direction)
-
getDirection
public ItemContext.SortDirection getDirection()
-
getPage
Page getPage()
-
addColumnDef
void addColumnDef(ColumnDef cd, ListColumnAction extensionColumn)
-
endColumnDefinitions
void endColumnDefinitions()
-
isColumnVisible
boolean isColumnVisible(String columnId)
-
isColumnSticky
boolean isColumnSticky(String columnId)
-
addFilteredColumn
void addFilteredColumn(String columnId, boolean visible)
-
writeColumnSubtitles
int writeColumnSubtitles(StringBuilder sb)
-
endColumnFilters
void endColumnFilters()
-
getSortDirection
ItemContext.SortDirection getSortDirection(String colum)
Get the sort direction on the given column. If it is not used for sorting, null is returned.- Since:
- 3.3
-
getDirectionImage
String getDirectionImage(ItemContext.SortDirection direction)
Get sort direction <img> element for the given direction. Return an empty string if direction = null.- Since:
- 3.3
-
getNextRowClass
String getNextRowClass()
-
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
public int doStartTag() throws JspException
- Specified by:
doStartTag
in interfaceTag
- Overrides:
doStartTag
in classTagSupport
- Throws:
JspException
-
doEndTag
public int doEndTag() throws JspException
- Specified by:
doEndTag
in interfaceTag
- Overrides:
doEndTag
in classTagSupport
- Throws:
JspException
-
-