Grid Class
- public class Grid
extends DataSourceTag
implements DataAccessProvider
, ErrorReporter
A <netui-data:grid...> tag is the containing tag of a tag set that renders regular data with
the ability to page, sort, and filter the data set. A grid renders
a table that represents the data in a data set. In addition, metadata
about the data set may be used to parameterize aspects of grid rendering.
The grid uses two objects to encapsulate its attributes and the data set that
is rendered. These items are:
The former is used to encapsulate the attributes set on the Grid tag, while the
latter is used to provide a consistent interface over different types of
data sets. This enables the tags to interact with the same interface regardless
of the type of data being displayed.
A grid renders a table in order to display the data. This table consists of three parts:
These parts are structured in a grid as follows:
column 1: header | column 2: header | column 3: header |
column 1: data cell | column 2: data cell | column 3: data cell |
column 1: data cell | column 2: data cell | column 3: data cell |
column 1: data cell | column 2: data cell | column 3: data cell |
column 1: footer | column 2: footer | column 3: footer |
The grid is rendered either automatically or by nesting tags of type
GridColumn
tags inside of a Columns
tag. The GridColumn tags are:
If the grid is automatically rendered, all parts of the table above are rendered from the data set.
The resulting Grid is not sortable or filterable. If the grid is rendered using its GridColumn,
each column renders a single cell for each row. Regardless of how a grid is rendered, a row is
rendered for each item in the data set, unless a
Pager
tag is used to set the page size.
The types that are supported for rendering in the grid are RowSet
.
Any other types that are passed to the grid via an expression in the dataSource attribute will
be illegal and an error will be reported in the JSP page.
Attribute Descriptions |
Attribute | Required | Runtime Expression Evaluation | Data Bindable |
autoRender | No | No | No |
A boolean specifying whether the grid should automatically render or should render using its body. |
dataSource | Yes | No | Yes |
An expression that references a data object which should be rendered by the grid.
Only data sets of type RowSet are supported.
|
name | Yes | No | Yes |
A unique identifier for this grid. |
Related Topics
<netui-data:grid> Tag Sample
Presenting Complex Data Sets in JSPs
Columns
-
Hierarchy
-
Object
TagSupport
BodyTagSupport
AbstractBaseTag
DataSourceTag
Grid
-
All Implemented Interfaces
-
BodyTag
, DataAccessProvider
, ErrorReporter
, IterationTag
, Serializable
, Tag
public static final int |
-
END
- A Grid rendering state that runs after the
Grid.FOOT_PAGER state has completed.
|
public static final int |
-
FOOT_PAGER
- A Grid rendering state that runs after the grid to give the optional
Pager the opportunity
to render after the grid renders.
|
public static final int |
-
FOOTER
- A Grid rendering state that runs when the Grid's columns are rendering their
footer cells.
|
public static final int |
-
HEAD_PAGER
- A Grid rendering state that runs to give the optional
Pager
the opportunity to render before the grid renders.
|
public static final int |
-
HEADER
- A Grid rendering state that runs when the Grid's columns are rendering their header cell.
|
public static final int |
-
INIT
- A Grid rendering state that runs on the Grid's first pass through its body.
|
public static final int |
-
ROWS
- A Grid rendering state that runs when the Grid's columns are rendering their data
cells.
|
public static final int |
-
START
- A Grid rendering state which signals that an error has occurred during rendering.
|
Fields from com.bea.wlw.netui.tags.AbstractBaseTag |
ATTR_GENERAL , ATTR_GENERAL_EXPRESSION , ATTR_JAVASCRIPT , ATTR_STYLE , CLASS , ID , JAVASCRIPT_STATUS , NAME , NETUI_UNIQUE_CNT , ONCLICK , ONDBLCLICK , ONKEYDOWN , ONKEYPRESS , ONKEYUP , ONMOUSEDOWN , ONMOUSEMOVE , ONMOUSEOUT , ONMOUSEOVER , ONMOUSEUP , STYLE , TABINDEX
|
Methods from com.bea.wlw.netui.tags.AbstractBaseTag |
addTagIdMapping , evaluateAttributeToString , filter , filter , getJavaScriptUtils , getNearestForm , getScriptReporter , getUserLocale , localRelease , registerTagError , release , renderAttribute , rewriteName , write
|
Methods from javax.servlet.jsp.tagext.TagSupport |
doAfterBody, doEndTag, doStartTag, findAncestorWithClass, getId, getParent, getValue, getValues, release, removeValue, setId, setPageContext, setParent, setValue |
Methods from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
END
public static final int END
- A Grid rendering state that runs after the
Grid.FOOT_PAGER
state has completed.
This state signals that the Grid has completed rendering.
FOOT_PAGER
public static final int FOOT_PAGER
- A Grid rendering state that runs after the grid to give the optional
Pager
the opportunity
to render after the grid renders. This state executes exactly once.
FOOTER
public static final int FOOTER
- A Grid rendering state that runs when the Grid's columns are rendering their
footer cells. In this state, there is no data available to the Grid on the
DataAccessProvider interface and expressions that reference the
container
context are invalid. This state executes
exactly once.
HEAD_PAGER
public static final int HEAD_PAGER
- A Grid rendering state that runs to give the optional
Pager
the opportunity to render before the grid renders. This state executes exactly once.
HEADER
public static final int HEADER
- A Grid rendering state that runs when the Grid's columns are rendering their header cell.
In this state, there is no data available to the Grid on the DataAccessProvider interface
and expressions that reference the
container
context are invalid.
This state executes exactly once.
INIT
public static final int INIT
- A Grid rendering state that runs on the Grid's first pass through its body. Initialization
by the child tags may occur on at this time. This state executes exactly once.
ROWS
public static final int ROWS
- A Grid rendering state that runs when the Grid's columns are rendering their data
cells. The data cells contain data that is extracted from the "current" data item.
This state executes once for each data item.
START
public static final int START
- A Grid rendering state which signals that an error has occurred during rendering.
Grid
public Grid()
addContent(String) Method
public final void addContent(String
content)
Add content to the content that is being buffered by this tag. All content
written by the body of this tag is added to this buffer. The buffer is rendered
at the end of the tag's lifecycle if no fatal errors have occurred during this
tag's lifecycle.
Parameters
-
content
- content that this tag should render.
addError(AbstractPageError) Method
public void addError(AbstractPageError
ape)
doAfterBody() Method
public int doAfterBody()
Conginue rendering the grid until it has passed through all of its rendering
states. This JSP lifecycle method transitions to the next grid rendering
state and advances through the dataset until each of the following rendering states
has completed:
- INIT
- HEAD_PAGER
- HEADER
- ROWS
- FOOTER
- FOOT_PAGER
- END
While the execution of these lifecycle states is ongoing, the body content
is buffered and added to the grid's content to render using the
Grid.addContent(String)
method. Once the END state is
reached, the body is skipped. Each of these stages makes a pass through
the tag's body once except for the ROWS state, which is executed once for
each item in the dataset.
-
Overrides
-
BodyTagSupport.doAfterBody()
Returns
- SKIP_BODY if in the END rendering state; EVAL_BODY_BUFFERED otherwise.
doEndTag() Method
public int doEndTag()
throws JspException
Render the content for the grid.
-
Overrides
-
BodyTagSupport.doEndTag()
Returns
- EVAL_PAGE
Exceptions
-
JspException
- if an error has occurred that can not be reported in the page
doStartTag() Method
public int doStartTag()
throws JspException
Start the rendering of the grid. The dataSource attribute is evaluated
as an expression and the result is converted into a DataContext
object. The body is rendered the first time in the INIT state.
-
Overrides
-
BodyTagSupport.doStartTag()
Returns
- EVAL_BODY_BUFFERED or SKIP_BODY if errors have occurred
Exceptions
-
JspException
- thrown when an error occurs during grid rendering that can not
be reported in the page.
getAutoRender() Method
public boolean getAutoRender()
Get a boolean that tells whether a grid will render automatically.
Returns
true
if the grid should automatically render; false
otherwise.
getContent() Method
public final String
getContent()
Get the content which should be rendered by this tag.
Returns
- the content String if there is content; null otherwise
getCurrentIndex() Method
public int getCurrentIndex()
Get the index of the current iteration through the body of this tag. This
data can be accessed using the expression container.index
on an attribute of a databindable NetUI tag that is contained within the
repeating body of this tag. This expression is only valid when the dataset
is being rendered.
Returns
- the integer index of the current data item in the data set
Related Topics
DataAccessProvider
getCurrentItem() Method
public Object
getCurrentItem()
Get the item that is currently being rendered by this repeating tag.
This can be accessed using the expression expression.item
on an attribute of a databindable NetUI tag that is contained within
the repeating body of this tag. The expression is only valid when the dataset
is being rendered.
Returns
- the current item in the data set
Related Topics
DataAccessProvider
getCurrentMetadata() Method
public Object
getCurrentMetadata()
Get the metadata for the current item. This method is not supported by
this tag.
Returns
- the current metadata or
null
if no metadata can be
found or metadata is not supported by a DataAccessProvider implementation
Related Topics
DataAccessProvider
getDataContext() Method
public final DataContext
getDataContext()
Returns
- the
DataContext
that is associated with a Grid tag
getDataSource() Method
public String
getDataSource()
Description copied from DataAccessProvider.getDataSource()
Get the expression that references the data item to which the
DataAccessProvider is bound.
-
Overrides
-
DataSourceTag.getDataSource()
Returns
- the expression referencing the data source or
null
if no
dataSource is set
getErrorsReport() Method
protected String
getErrorsReport()
-
Overrides
-
AbstractBaseTag.getErrorsReport()
getGridContext() Method
public final GridContext
getGridContext()
Returns
- the
GridContext
that is associated with a Grid tag
getImageRoot() Method
public String
getImageRoot()
getName() Method
public String
getName()
Get the name of a grid.
Returns
- the String name of the grid or an expression
that references a String name of the grid
getProviderParent() Method
public DataAccessProvider
getProviderParent()
Get the parent DataAccessProvider for this tag. If this tag is contained within
a DataAccessProvider, the containing DataAccessProvider is available through the
expression container.container
. Any valid properties of the
parent DataAccessProvider can be accessed through this expression. This method
will return null if there is no parent DataAccessProvider
Returns
- a containing DataAccessProvider if one exists, null otherwise.
Related Topics
DataAccessProvider
getRenderState() Method
public int getRenderState()
Get the current render state for the Grid. This tag is used by child tags
to access the current location in the Grid's rendering lifecycle.
Returns
- an integer that represents the current state of the grid; this is one
of
Grid.START
, Grid.INIT
, Grid.HEAD_PAGER
, Grid.HEADER
, Grid.ROWS
,
Grid.FOOTER
, Grid.FOOT_PAGER
, or Grid.END
getTagName() Method
public String
getTagName()
Get the name of this tag. This is used to identify the type of this tag
for reporting tag errors.
-
Overrides
-
AbstractBaseTag.getTagName()
Returns
- a constant String representing the name of this tag.
hasErrors() Method
protected boolean hasErrors()
-
Overrides
-
AbstractBaseTag.hasErrors()
isReporting() Method
public boolean isReporting()
Description copied from ErrorReporter.isReporting()
This boolean indicates if an ErrorReporter is reporting errors
or not. The caller should check this before calling addError
because the ErrorReporter may be off for some reason.
Returns
- a boolean indicating if the tag is reporting errors or not.
localRelease() Method
protected void localRelease()
Reset all of the fields of this tag.
-
Overrides
-
DataSourceTag.localRelease()
returnErrors() Method
public ArrayList
returnErrors()
Description copied from ErrorReporter.returnErrors()
Return an ArrayList of the errors
Returns
- an
ArrayList
of all errors.
setAutoRender(boolean) Method
public void setAutoRender(boolean autoRender)
Set a boolean that tells a Grid to render it self automatically. Automatic
rendering of a dataset bypasses any user paramteerization in the body of the
Grid and disallows several grid features including sorts, filters, and paging.
Parameters
-
autoRender
- a boolean signifying whether a grid should automatically render.
If
true
auto render; otherwise render using the tags in the grid's
body.
setDataSource(String) Method
public void setDataSource(String
dataSource)
Set the dataSource attribute. The dataSource attribute is an
expression that references an object whose data
will be rendered by the Grid.
-
Overrides
-
DataSourceTag.setDataSource(String)
Parameters
-
dataSource
- an expression that references a data object
setGridStyle(GridStyleContext) Method
public void setGridStyle(GridStyleContext
gridStyle)
Set the GridStyleContext
that
encapsulates the style information for a Grid tag. A GridStyleContext
is
created by the GridStyle
tag in order to
parameterize the Grid with style information. The context is set here because it will
be reused in many states during a Grid tag's lifecycle, and the specific GridStyle
tag may not be valid when the style information is needed.
Returns
- a
GridStyleContext
object
that encapsulates the style information for a Grid tag
setImageRoot(String) Method
public void setImageRoot(String
imageRoot)
setName(String) Method
public void setName(String
name)
Set the name of a grid. The name attribute of a grid is used to identify
parameters in the URL that further parameterize how a grid is rendered.
Specifically, the URL contains information about any sorts and filters
that may be applied to a dataset that is associated with a grid. Grid
names should be unique within the scope of the pages where the grid
may exist; if a <netui-data:grid> exists in a Page Flow, its grid name should be
unique across the page flow so that parameters in the URL which
are scoped to a particular grid on a particular page do not collide.
Parameters
-
name
- the String name of the grid or an expression that references a String name of the grid