BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.

com.bea.wlw.netui.tags.databinding.grid
Class Grid

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by com.bea.wlw.netui.tags.AbstractBaseTag
              extended by com.bea.wlw.netui.tags.DataSourceTag
                  extended by com.bea.wlw.netui.tags.databinding.grid.Grid
All Implemented Interfaces:
DataAccessProvider, ErrorReporter, HtmlConstants, Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

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: headercolumn 2: headercolumn 3: header
column 1: data cellcolumn 2: data cellcolumn 3: data cell
column 1: data cellcolumn 2: data cellcolumn 3: data cell
column 1: data cellcolumn 2: data cellcolumn 3: data cell
column 1: footercolumn 2: footercolumn 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 javax.sql.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
AttributeRequiredRuntime Expression EvaluationData Bindable
autoRenderNoNoNo
A boolean specifying whether the grid should automatically render or should render using its body.
dataSourceYesNoYes
An expression that references a data object which should be rendered by the grid. Only data sets of type javax.sql.RowSet are supported.
nameYesNoYes
A unique identifier for this grid.

See Also:
Columns, Serialized Form
Example:

This sample shows a <netui-data:grid> tag that writes out two AnchorColumn and one BasicColumn.

   <netui-data:grid dataSource="{pageFlow.allRows}" name="{pageFlow.gridName}">
         <netui-data:gridStyle styleClassPrefix="gridStyle"/>
         <netui-data:pager renderInHeader="true" action="pageAction" renderInFooter="true"/>
             <netui-data:columns filterAction="begin" sortAction="begin">
                 <netui-data:anchorColumn action="detailsItems" addRowId="true" title="Details"/>
                 <netui-data:anchorColumn action="updateItems" addRowId="true" title="Edit"/>
                 <netui-data:basicColumn filterable="true" title="Itemnumber" sortable="true" name="itemnumber"/>
             </netui-data:columns>
     </netui-data:grid>

Code Sample

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui_databinding/grid/grid.jsp
Beadoc.see:
<netui-data:grid> Tag Sample, Presenting Complex Data Sets in JSPs
Beadoc.tagdescription:
The <netui-data:grid> tag renders data sets as an HTML table with the ability to page, sort, and filter the data set. In addition, metadata about the data set may be used to effect aspects of the rendering.

The rendered table consists of three parts:

  • header
  • data rows
  • footer

These parts are structured in a grid as follows:

column 1: headercolumn 2: headercolumn 3: header
column 1: data cellcolumn 2: data cellcolumn 3: data cell
column 1: data cellcolumn 2: data cellcolumn 3: data cell
column 1: data cellcolumn 2: data cellcolumn 3: data cell
column 1: footercolumn 2: footercolumn 3: footer

The grid is rendered either automatically or by nesting the following tags inside of a Columns tag:

If the grid is automatically rendered, the resulting HTML table is not sortable or filterable. 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.

javax.sql.RowSet is the only type supported for rendering by the <netui-data:grid>. Any other types that are passed to the grid are illegal and an error will be reported in the JSP page.


Field Summary
static int END
          A Grid rendering state that runs after the FOOT_PAGER state has completed.
static 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.
static int FOOTER
          A Grid rendering state that runs when the Grid's columns are rendering their footer cells.
static int HEAD_PAGER
          A Grid rendering state that runs to give the optional Pager the opportunity to render before the grid renders.
static int HEADER
          A Grid rendering state that runs when the Grid's columns are rendering their header cell.
static int INIT
          A Grid rendering state that runs on the Grid's first pass through its body.
static int ROWS
          A Grid rendering state that runs when the Grid's columns are rendering their data cells.
static int START
          A Grid rendering state which signals that an error has occurred during rendering.
 
Fields inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
ATTR_GENERAL, ATTR_GENERAL_EXPRESSION, ATTR_JAVASCRIPT, ATTR_STYLE, JAVASCRIPT_STATUS, NETUI_UNIQUE_CNT
 
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 com.bea.wlw.netui.tags.ErrorReporter
CONTAINER_ERRORS
 
Fields inherited from interface com.bea.wlw.netui.tags.html.HtmlConstants
ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEIGHT, HREF, HREFLANG, HSPACE, HTML, ID, IMAGE, INPUT, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, INPUT_PASSWORD, INPUT_RADIO, INPUT_RESET, INPUT_SUBMIT, INPUT_TEXT, ISMAP, LABEL, LANG, LINK, LONGDESC, MAXLENGTH, METHOD, NAME, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONLOAD, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, ONRESET, ONSELECT, ONSUBMIT, ONUNLOAD, OPTION, READONLY, REL, REV, RULES, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TD, TEXT, TEXTAREA, TITLE, TR, TYPE, USEMAP, VALIGN, VALUE, VLINK, VSPACE, WIDTH
 
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
Grid()
           
 
Method Summary
 void addContent(String content)
          Add content to the content that is being buffered by this tag.
 void addError(AbstractPageError ape)
           
 int doAfterBody()
          Conginue rendering the grid until it has passed through all of its rendering states.
 int doEndTag()
          Render the content for the grid.
 int doStartTag()
          Start the rendering of the grid.
 boolean getAutoRender()
          Get a boolean that tells whether a grid will render automatically.
 String getContent()
          Get the content which should be rendered by this tag.
 int getCurrentIndex()
          Get the index of the current iteration through the body of this tag.
 Object getCurrentItem()
          Get the item that is currently being rendered by this repeating tag.
 Object getCurrentMetadata()
          Get the metadata for the current item.
 DataContext getDataContext()
           
 String getDataSource()
          Gets the tag's data source (can be an expression).
protected  String getErrorsReport()
           
 GridContext getGridContext()
           
 String getImageRoot()
           
 String getName()
          Get the name of a grid.
 DataAccessProvider getProviderParent()
          Get the parent DataAccessProvider for this tag.
 int getRenderState()
          Get the current render state for the Grid.
 String getTagName()
          Get the name of this tag.
protected  boolean hasErrors()
           
 boolean isReporting()
          This boolean indicates if an ErrorReporter is reporting errors or not.
protected  void localRelease()
          Reset all of the fields of this tag.
 ArrayList returnErrors()
          Return an ArrayList of the errors
 void setAutoRender(boolean autoRender)
          Set a boolean that tells a Grid to render it self automatically.
 void setDataSource(String dataSource)
          Set the dataSource attribute.
 void setGridStyle(GridStyleContext gridStyle)
          Set the GridStyleContext that encapsulates the style information for a Grid tag.
 void setImageRoot(String imageRoot)
           
 void setName(String name)
          Set the name of a grid.
 
Methods inherited from class com.bea.wlw.netui.tags.DataSourceTag
addNamingInterceptor, doNaming, evaluateDataSource, qualifyAttribute, removeNamingInterceptor
 
Methods inherited from class com.bea.wlw.netui.tags.AbstractBaseTag
addTagIdMapping, containsExpression, evaluateAttributeToString, evaluateExpression, filter, filter, formatErrorString, formatString, getAttribute, getExpressionEvaluator, getJavaScriptUtils, getNearestForm, getNextId, getQualifiedBundleName, getScriptReporter, getUserLocale, isExpression, prepForRendering, registerAttribute, registerError, registerTagError, release, removeAttribute, renderAttribute, renderAttributes, reportErrors, rewriteName, setPageContext, updateExpression, write
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, 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, setParent
 

Field Detail

START

public static final int START
A Grid rendering state which signals that an error has occurred during rendering.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

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.

See Also:
Constant Field Values

END

public static final int END
A Grid rendering state that runs after the FOOT_PAGER state has completed. This state signals that the Grid has completed rendering.

See Also:
Constant Field Values
Constructor Detail

Grid

public Grid()
Method Detail

setImageRoot

public void setImageRoot(String imageRoot)
Beadoc.attributedescription:
The image root.
Beadoc.attributesyntaxvalue:
string_imageRoot
Beadoc.databindable:
false

getImageRoot

public String getImageRoot()

getTagName

public String getTagName()
Get the name of this tag. This is used to identify the type of this tag for reporting tag errors.

Specified by:
getTagName in class AbstractBaseTag
Returns:
a constant String representing the name of this tag.

getDataContext

public final DataContext getDataContext()
Returns:
the DataContext that is associated with a Grid tag

getGridContext

public final GridContext getGridContext()
Returns:
the GridContext that is associated with a Grid tag

addContent

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.

getContent

public final String getContent()
Get the content which should be rendered by this tag.

Returns:
the content String if there is content; null otherwise

setName

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
Beadoc.attributedescription:
The name attribute of a grid is used to identify parameters in the URL that further determine how the HTML table is rendered. Specifically, the URL contains information about any sorts and filters that may be applied to a data set. The attribute should be 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.
Beadoc.attributesyntaxvalue:
string_or_expression_name
Beadoc.databindable:
true

getName

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

setAutoRender

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.
Beadoc.attributedescription:
A boolean that tells a <netui-data:grid> to render itself automatically. Automatic rendering of a dataset bypasses any user paramertization in rendering of the HTML table and disallows several features including sorts, filters, and paging.
Beadoc.attributesyntaxvalue:
boolean_autoRender
Beadoc.databindable:
false

getAutoRender

public boolean getAutoRender()
Get a boolean that tells whether a grid will render automatically.

Returns:
true if the grid should automatically render; false otherwise.

getRenderState

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 START, INIT, HEAD_PAGER, HEADER, ROWS, FOOTER, FOOT_PAGER, or END

setGridStyle

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.


doStartTag

public int doStartTag()
               throws javax.servlet.jsp.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.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
EVAL_BODY_BUFFERED or SKIP_BODY if errors have occurred
Throws:
javax.servlet.jsp.JspException - thrown when an error occurs during grid rendering that can not be reported in the page.

doAfterBody

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:
  1. INIT
  2. HEAD_PAGER
  3. HEADER
  4. ROWS
  5. FOOTER
  6. FOOT_PAGER
  7. 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 addContent(java.lang.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.

Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Overrides:
doAfterBody in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
SKIP_BODY if in the END rendering state; EVAL_BODY_BUFFERED otherwise.

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Render the content for the grid.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
EVAL_PAGE
Throws:
javax.servlet.jsp.JspException - if an error has occurred that can not be reported in the page

localRelease

protected void localRelease()
Reset all of the fields of this tag.

Overrides:
localRelease in class DataSourceTag

addError

public void addError(AbstractPageError ape)
Specified by:
addError in interface ErrorReporter

hasErrors

protected boolean hasErrors()
Overrides:
hasErrors in class AbstractBaseTag

isReporting

public boolean isReporting()
Description copied from interface: ErrorReporter
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.

Specified by:
isReporting in interface ErrorReporter
Returns:
a boolean indicating if the tag is reporting errors or not.

returnErrors

public ArrayList returnErrors()
Description copied from interface: ErrorReporter
Return an ArrayList of the errors

Specified by:
returnErrors in interface ErrorReporter
Returns:
an ArrayList of all errors.

getErrorsReport

protected String getErrorsReport()
Overrides:
getErrorsReport in class AbstractBaseTag

getCurrentIndex

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.

Specified by:
getCurrentIndex in interface DataAccessProvider
Returns:
the integer index of the current data item in the data set
See Also:
DataAccessProvider

getCurrentItem

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.

Specified by:
getCurrentItem in interface DataAccessProvider
Returns:
the current item in the data set
See Also:
DataAccessProvider

getDataSource

public String getDataSource()
Description copied from class: DataSourceTag
Gets the tag's data source (can be an expression).

Specified by:
getDataSource in interface DataAccessProvider
Overrides:
getDataSource in class DataSourceTag
Returns:
the data source

setDataSource

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.

Specified by:
setDataSource in interface DataAccessProvider
Overrides:
setDataSource in class DataSourceTag
Parameters:
dataSource - an expression that references a data object
Beadoc.attributedescription:
A data binding expression that references the data set to be rendered by the <netui-data:grid>. This expression must resolve to an object of type javax.sql.RowSet or an error will be thrown and reported inline on the JSP page.
Beadoc.attributesyntaxvalue:
expression_dataSource
Beadoc.databindable:
true

getCurrentMetadata

public Object getCurrentMetadata()
Get the metadata for the current item. This method is not supported by this tag.

Specified by:
getCurrentMetadata in interface DataAccessProvider
Returns:
the current metadata or null if no metadata can be found or metadata is not supported by a DataAccessProvider implementation
Throws:
UnsupportedOperationException - this tag does not support this method from the DataAccessProvider interface
See Also:
DataAccessProvider

getProviderParent

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

Specified by:
getProviderParent in interface DataAccessProvider
Returns:
a containing DataAccessProvider if one exists, null otherwise.
See Also:
DataAccessProvider

BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs.