org.opensubsystems.patterns.listdata.www
Class ListTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by org.opensubsystems.core.www.PageElementCacheTag
              extended by org.opensubsystems.patterns.listdata.www.ListTag
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public abstract class ListTag
extends org.opensubsystems.core.www.PageElementCacheTag

Custom tag to construct all required elements of scrollable and browsable table of data objects. It is mainly used by datalist.jsp layout.

Version:
$Id: ListTag.java,v 1.70 2007/02/01 07:25:20 bastafidli Exp $
Author:
Julo Legeny
See Also:
Serialized Form
Code reviewer:
Miro Halas
Code reviewed:
1.62 2006/04/14 00:42:30

Field Summary
protected static int CHECKBOX_COLUMN_WIDTH
          Constant defining length in percentage of the row width that will be used for checkbox column width if the flag specifying to display checkboxes in each row is set.
protected static java.lang.String FUNCTION_BODY
          Function parameter for getting body.
protected static java.lang.String FUNCTION_COLS
          Function parameter for getting columns.
protected static java.lang.String FUNCTION_FILTER
          Function parameter for getting init data for filter
protected static java.lang.String FUNCTION_HEADINGS
          Function parameter for getting headings.
protected static java.lang.String FUNCTION_MESSAGES
          Function parameter for getting init data for messages
protected static java.lang.String FUNCTION_SORT
          Function parameter for getting init data for sorting
protected  int[] m_arrDefaultListColumns
          Array of columns specifying what columns to display in a list by default and in what order.
protected  int[] m_arrDefaultOrderColumns
          Array of columns specifying what columns should be used to sort by default on gui.
protected  java.lang.String[] m_arrDefaultOrderDirections
          Array of ListDefinition.ORDER_XXX constants specifying the default directions for the default list of columns used for sorting.
protected  boolean m_bLink
          Flag if the list should contain a link.
protected  java.util.Map m_mapColumnDefinitions
          Map defining what columns are available for this list.
protected  java.lang.String m_strCheck
          Flag if the list should contain a checkboxes included in each row.
protected  java.lang.String m_strCheckDefault
          Default value for m_strCheck.
protected  java.lang.String m_strData
          Name of the attribute which identifies the list of data objects.
protected  java.lang.String m_strDataTypeName
          Identificator of type of data shown in table.
protected  java.lang.String m_strFunction
          Name of the function (element), which should be created by this tag.
protected  java.lang.String m_strLimit
          Number specified limit for assigned items within the table.
protected  java.lang.String m_strOptions
          Name of the attribute which identifies ListOptions object.
protected  java.lang.String m_strSortable
          Flag if the list should be sorted.
protected  java.lang.String m_strSortableDefault
          Default value for m_strSortable.
protected  java.lang.String m_strTableId
          Id of the table.
protected static ColumnDefinition UNKNOWN_COLUMN
          This definition will be used whenever code specified to use unknown column so that we do not present error on the screen.
 
Fields inherited from class org.opensubsystems.core.www.PageElementCacheTag
CACHE_INDICATOR, CSS_ELEMENT, JS_ELEMENT, m_strCacheas, m_strId, PAGE_ELEMENTS_CACHE, SCRIPT_ELEMENT
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
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
ListTag(java.lang.String strDataTypeName, int[] arrDefaultListColumns, int[] arrDefaultOrderColumns, java.lang.String[] arrDefaultOrderDirections, java.util.Map mapColumnDefinitions)
          Constructor for custom tag.
 
Method Summary
 int doEndTag()
          Evaluate the remainder of the current page normally.
 int doStartTag()
          Perform the test required for this particular tag, and either evaluate or skip the body of this tag.
protected  void generateTableCell(java.lang.StringBuffer sbBuffer, java.lang.String strText, int iLimit, java.lang.String strLink, java.lang.String strClass)
          Generate the HTML for the table cell (<td> tag body)
protected abstract  void getBodyDefinition(int iColumnId, int iCounter, int iItemCounter, java.lang.Object objListItem, java.lang.StringBuffer sbHtml)
          Generate the HTML for the body definition
 java.lang.String getCheck()
          Get the flag if the list should contain a checkboxes included in each row.
protected  ColumnDefinition getColumnDefinition(int iColumnId, int iCounter, java.lang.String strFunction)
          Generate the HTML for the column definition
protected  void getColumnDefinition(int iColumnId, int iCounter, java.lang.String strFunction, ColumnDefinition outDefinition)
          Generate the HTML for the column definition
 java.lang.String getData()
          Get the name of the attribute which identifies the list of data objects.
protected  java.lang.String getDataTypeName()
          Get identificator of type of data shown in table.
protected  int[] getDefaultListColumns()
          Get array of columns specifying what columns to display in a list by default and in what order.
protected  int[] getDefaultOrderColumns()
          Get array of columns specifying what columns should be used to sort by default on gui.
protected  java.lang.String[] getDefaultOrderDirections()
          Get default directions for the default list of columns used for sorting.
 java.lang.String getFunction()
          Get the name of the function (element), which should be created by this tag.
 boolean getLink()
          Get the flag if the list should contain a link.
 java.lang.String getOptions()
          Get the name of the attribute which identifies ListOptions object.
protected  java.lang.String getRowId(java.lang.Object objListItem)
          Get row id String for data object row.
 boolean isCheckActive()
           
protected  boolean isFilter()
          Function returns flag signaling if there is used filter list or not.
 boolean isSortableActive()
           
protected  void processFunction(java.lang.String strFunction)
          Method process particular function
 void release()
          Release all allocated resources.
 void setCheck(java.lang.String strCheck)
          Set flag if the list should contain a checkboxes included in each row.
 void setData(java.lang.String strData)
          Set the name of the attribute which identifies the list of data objects.
 void setFunction(java.lang.String strFunction)
          Sets the name of the function (element), which should be created by this tag.
 void setLink(boolean bLink)
          Set the flag if the list should contain a link.
 void setOptions(java.lang.String strName)
          Sets the name of the attribute which identifies ListOptions object.
 
Methods inherited from class org.opensubsystems.core.www.PageElementCacheTag
cache, getCacheas, getCachedContent, getCachedContent, getCachedContent, getCachedContentElements, getId, setCacheas, setId
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getParent, getValue, getValues, removeValue, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Field Detail

CHECKBOX_COLUMN_WIDTH

protected static final int CHECKBOX_COLUMN_WIDTH
Constant defining length in percentage of the row width that will be used for checkbox column width if the flag specifying to display checkboxes in each row is set.

See Also:
Constant Field Values

FUNCTION_HEADINGS

protected static final java.lang.String FUNCTION_HEADINGS
Function parameter for getting headings.

See Also:
Constant Field Values

FUNCTION_COLS

protected static final java.lang.String FUNCTION_COLS
Function parameter for getting columns.

See Also:
Constant Field Values

FUNCTION_SORT

protected static final java.lang.String FUNCTION_SORT
Function parameter for getting init data for sorting

See Also:
Constant Field Values

FUNCTION_FILTER

protected static final java.lang.String FUNCTION_FILTER
Function parameter for getting init data for filter

See Also:
Constant Field Values

FUNCTION_MESSAGES

protected static final java.lang.String FUNCTION_MESSAGES
Function parameter for getting init data for messages

See Also:
Constant Field Values

FUNCTION_BODY

protected static final java.lang.String FUNCTION_BODY
Function parameter for getting body.

See Also:
Constant Field Values

UNKNOWN_COLUMN

protected static final ColumnDefinition UNKNOWN_COLUMN
This definition will be used whenever code specified to use unknown column so that we do not present error on the screen.


m_strOptions

protected java.lang.String m_strOptions
Name of the attribute which identifies ListOptions object. Required.


m_strData

protected java.lang.String m_strData
Name of the attribute which identifies the list of data objects. Required.


m_strFunction

protected java.lang.String m_strFunction
Name of the function (element), which should be created by this tag. This is one of the FUNCTION_XXX constants defined in this class. Required.


m_strCheck

protected java.lang.String m_strCheck
Flag if the list should contain a checkboxes included in each row. These checkboxes will be used for selecting particular item (row) in the list. This attribute should say true or 1. Not required.


m_strCheckDefault

protected java.lang.String m_strCheckDefault
Default value for m_strCheck.


m_strSortable

protected java.lang.String m_strSortable
Flag if the list should be sorted. This attribute should say true or 1. Not required.


m_strSortableDefault

protected java.lang.String m_strSortableDefault
Default value for m_strSortable.


m_strTableId

protected java.lang.String m_strTableId
Id of the table. Not required.


m_bLink

protected boolean m_bLink
Flag if the list should contain a link. Not required. TODO: Improve: How is this really used?


m_strLimit

protected java.lang.String m_strLimit
Number specified limit for assigned items within the table. limit = 0 ... no limit limit = X (X > 0) ... max. X items can be assigned in the list


m_strDataTypeName

protected java.lang.String m_strDataTypeName
Identificator of type of data shown in table. This should be constant that can be safely used to generate JavaScript identificators and should be also convertible to data type code using the methods in DataConstant class.


m_arrDefaultListColumns

protected int[] m_arrDefaultListColumns
Array of columns specifying what columns to display in a list by default and in what order.


m_arrDefaultOrderColumns

protected int[] m_arrDefaultOrderColumns
Array of columns specifying what columns should be used to sort by default on gui.


m_arrDefaultOrderDirections

protected java.lang.String[] m_arrDefaultOrderDirections
Array of ListDefinition.ORDER_XXX constants specifying the default directions for the default list of columns used for sorting. The array has to have the same length as the one specified in m_arrDefaultOrderColumns where the order for column specified at index i will be specified at the same index.


m_mapColumnDefinitions

protected java.util.Map m_mapColumnDefinitions
Map defining what columns are available for this list. Key is Integer column code and value is ColumnDefinition describing that column.

Constructor Detail

ListTag

public ListTag(java.lang.String strDataTypeName,
               int[] arrDefaultListColumns,
               int[] arrDefaultOrderColumns,
               java.lang.String[] arrDefaultOrderDirections,
               java.util.Map mapColumnDefinitions)
Constructor for custom tag.

Parameters:
strDataTypeName - - id of type of data shown in table. This should be constant that can be safely used to generate JavaScript identificators and should be also convertible to data type code using the methods in DataConstant class.
arrDefaultListColumns - - array of columns specifying what columns to display in a list by default and in what order.
arrDefaultOrderColumns - - array of columns specifying what columns should be used to sort by default on gui.
arrDefaultOrderDirections - - array of ListDefinition.ORDER_XXX constants specifying the default directions for the default list of columns used for sorting. The array has to have the same length as the one specified in arrDefaultOrderColumns where the order for column specified at index i will be specified at the same index.
mapColumnDefinitions - - map of column definition where key is the identification of the column (Integer constant) and value is ColumnDefinition object.
Method Detail

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Perform the test required for this particular tag, and either evaluate or skip the body of this tag. This method really determines what

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class org.opensubsystems.core.www.PageElementCacheTag
Returns:
int - predefined constant
Throws:
javax.servlet.jsp.JspException - if a JSP exception occurs

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Evaluate the remainder of the current page normally.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class org.opensubsystems.core.www.PageElementCacheTag
Returns:
int - predefined constant
Throws:
javax.servlet.jsp.JspException - if a JSP exception occurs

release

public void release()
Release all allocated resources.

Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class javax.servlet.jsp.tagext.BodyTagSupport

getOptions

public java.lang.String getOptions()
Get the name of the attribute which identifies ListOptions object. Required.

Returns:
String - name of the attribute which identifies ListOptions object

setOptions

public void setOptions(java.lang.String strName)
Sets the name of the attribute which identifies ListOptions object. Required.

Parameters:
strName - - name of the attribute which identifies ListOptions object

getData

public java.lang.String getData()
Get the name of the attribute which identifies the list of data objects. Required.

Returns:
name of the list

setData

public void setData(java.lang.String strData)
Set the name of the attribute which identifies the list of data objects. Required.

Parameters:
strData - - name of the attribute which identifies the list of data objects

getFunction

public java.lang.String getFunction()
Get the name of the function (element), which should be created by this tag. This is one of the FUNCTION_XXX constants defined in this class. Required.

Returns:
String - name of the function

setFunction

public void setFunction(java.lang.String strFunction)
Sets the name of the function (element), which should be created by this tag. This is one of the FUNCTION_XXX constants defined in this class. Required.

Parameters:
strFunction - - function that will be set

getLink

public boolean getLink()
Get the flag if the list should contain a link. Not required.

Returns:
boolean - flag if the list should contain a link. Not required.

setLink

public void setLink(boolean bLink)
Set the flag if the list should contain a link. Not required.

Parameters:
bLink - - Flag if the list should contain a link

getCheck

public java.lang.String getCheck()
Get the flag if the list should contain a checkboxes included in each row. Not required.

Returns:
String - flag value

setCheck

public void setCheck(java.lang.String strCheck)
Set flag if the list should contain a checkboxes included in each row. These checkboxes will be used for selecting particular item (row) in the list. Not required.

Parameters:
strCheck - - name of the attribute which identifies the flag

getColumnDefinition

protected void getColumnDefinition(int iColumnId,
                                   int iCounter,
                                   java.lang.String strFunction,
                                   ColumnDefinition outDefinition)
Generate the HTML for the column definition

Parameters:
iColumnId - - column code of the specific table
iCounter - - counter for the position of the column width in the float array
strFunction - - the type of the function (headings, cols, body)
outDefinition - - definition of the column is output parameter which will be filled out so that we optimize the performance

getColumnDefinition

protected ColumnDefinition getColumnDefinition(int iColumnId,
                                               int iCounter,
                                               java.lang.String strFunction)
Generate the HTML for the column definition

Parameters:
iColumnId - - column code of the specific table
iCounter - - counter for the position of the column width in the float array
strFunction - - the type of the function (headings, cols, body)
Returns:
ColumnDefinition - definition for the requested column

getBodyDefinition

protected abstract void getBodyDefinition(int iColumnId,
                                          int iCounter,
                                          int iItemCounter,
                                          java.lang.Object objListItem,
                                          java.lang.StringBuffer sbHtml)
Generate the HTML for the body definition

Parameters:
iColumnId - - column code of the specific table
iCounter - - counter for the position of the column width in the float array
iItemCounter - - counter of actual processed item
objListItem - - particular object from the list
sbHtml - - out HTML string buffer

getRowId

protected java.lang.String getRowId(java.lang.Object objListItem)
Get row id String for data object row. By default it is the id of the data object.

Parameters:
objListItem - - particular object from the list
Returns:
String - String representing row id

getDefaultListColumns

protected int[] getDefaultListColumns()
Get array of columns specifying what columns to display in a list by default and in what order.

Returns:
int[] - list column codes

getDefaultOrderColumns

protected int[] getDefaultOrderColumns()
Get array of columns specifying what columns should be used to sort by default on gui.

Returns:
int[] - list column codes

getDefaultOrderDirections

protected java.lang.String[] getDefaultOrderDirections()
Get default directions for the default list of columns used for sorting. The returned array has to have the same length as the one returned from getDefaultOrderColumns where the order for column specified at index i will be specified at the same index.

Returns:
String[] - ListDefinition.ORDER_XXX constants

getDataTypeName

protected java.lang.String getDataTypeName()
Get identificator of type of data shown in table. This should be constant that can be safely used to generate JavaScript identificators and should be also convertible to data type code using the methods in DataConstant class.

Returns:
String - type of data showed in table

generateTableCell

protected void generateTableCell(java.lang.StringBuffer sbBuffer,
                                 java.lang.String strText,
                                 int iLimit,
                                 java.lang.String strLink,
                                 java.lang.String strClass)
Generate the HTML for the table cell (<td> tag body)

Parameters:
sbBuffer - - StringBuffer to add table cell code to
strText - - full length text to add
iLimit - - limit of length to show (0 - no limit)
strLink - - href for <a> tag (null - no link)
strClass - - class of <td> tag (null - no class)

processFunction

protected void processFunction(java.lang.String strFunction)
                        throws javax.servlet.jsp.JspException
Method process particular function

Parameters:
strFunction - - function that has to be processed
Throws:
javax.servlet.jsp.JspException - - error occured

isCheckActive

public boolean isCheckActive()
Returns:
boolean - true if checkbox will be present in each row of the table

isSortableActive

public boolean isSortableActive()
Returns:
boolean - true if table columns will be sortable

isFilter

protected boolean isFilter()
Function returns flag signaling if there is used filter list or not.

Returns:
boolean - frue = there is used list of filters - false = there is used list of dataobjects


Copyright © 2003 - 2006 OpenSubsystems s.r.o.