org.apache.beehive.netui.databinding.datagrid.api.rendering
Class DataGridTagModel

Object
  extended by DataGridTagModel

public class DataGridTagModel
extends Object

The DataGridTagModel is a JavaBean that is exposed by the NetUI data grid tag into the PageContext in a JSP. This bean exposes state and services which can be data bound by an expression language in a JSP.


Field Summary
static int RENDER_STATE_CAPTION
          The render state used when the data grid is rendering the caption tag.
static int RENDER_STATE_END
          The render state used when the data grid has completed rendering.
static int RENDER_STATE_FOOTER
          The render state used when the data grid is rendering the footer.
static int RENDER_STATE_GRID
          The render state used when the data grid is rendering the data rows.
static int RENDER_STATE_HEADER
          The render state used when the data grid is rendering the header tag.
static int RENDER_STATE_START
          The render state used when the data grid performs its first pass through its tag body.
 
Constructor Summary
DataGridTagModel(String name, DataGridConfig dataGridConfig, JspContext jspContext)
          Constructor used to build a DataGridTagModel.
 
Method Summary
 void addResourceOverride(String key, String value)
           This method provides support for overriding the messages available in the DataGridResourceProvider on a per-message basis.
 void changeRenderState(int renderState)
           Method that alters the data grid's current render to the new renderState.
 String formatMessage(String key, Object[] args)
          Format a message given a resource string name key and a set of formatting arguments args.
 int getCurrentIndex()
          Accessor for obtaining the current index in the data set.
 Object getCurrentItem()
          Accessor for obtaining the current item in the data set.
 PagedDataSet getDataSet()
          Accessor for the PagedDataSet that is used to render a data set in the grid.
 String getDataSource()
          Accessor for obtaining the data source expression that was used to data bind to the data set.
 String getDefaultSortImagePath()
          Get the default image path used when constructing links to sort images.
 JspContext getJspContext()
          Accessor for the JspContext for the JSP in which the grid started to render.
 String getMessage(String key)
          Get a message given a resource string name key.
 String getName()
          Accessor for the name of the data grid.
 PagerRenderer getPagerRenderer()
          Accessor for the PagerRenderer.
 int getRenderState()
           Accessor for the current render state.
 String getResourcePath()
           Get the resourrce path used when creating HTML image links during data grid rendering.
 DataGridResourceProvider getResourceProvider()
          Get the DataGridResourceProvider used to provide string messages, paths, etc during data grid rendering.
 String getSortImagePath(SortDirection sortDirection)
           Get the image paths used for the given SortDirection.
 DataGridState getState()
          Accessor for obtaining the DataGridState object.
 StyleModel getStyleModel()
          Get the StyleModel used to create style classes during data grid rendering.
 TableRenderer getTableRenderer()
          Get the instance of TableRenderer that is used to render HTML table markup for a data grid.
 DataGridURLBuilder getUrlBuilder()
          Accessor for obtaining the DataGridURLBuilder object.
 boolean hasNextDataItem()
          Accessor for determining if there is another item in the data set.
 boolean isDisableDefaultPagerRendering()
          Check to see if the data grid will render its pager UI by default.
 boolean isRenderRowGroups()
           Get the flag for whether to render the data grid using HTML row groups.
 Object nextDataItem()
          Accessor for getting the next item in the data set.
 void renderPager(AbstractRenderAppender appender)
          Method used to render the data grid's pager UI into the given AbstractRenderAppender.
 void setDataSet(PagedDataSet dataSet)
          Setter for the PagedDataSet object.
 void setDisableDefaultPagerRendering(boolean disableDefaultPagerRendering)
          Set a boolean to enable or disable rendering the pager UI by default.
 void setPagerRenderer(PagerRenderer pagerRenderer)
          Set the PagerRenderer used to render the paging UI for the data grid.
 void setRenderRowGroups(boolean renderRowGroups)
          Set whether to render the data grid using HTML row groups.
 void setResourceProvider(DataGridResourceProvider resourceProvider)
          Set the DataGridResourceProvider used to render the data grid.
 void setStyleModel(StyleModel styleModel)
          Set the StyleModel used to create style classes during data grid rendering.
 void setTableRenderer(TableRenderer tableRenderer)
          Set the TableRenderer used to render HTML table markup for a data grid.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RENDER_STATE_START

public static final int RENDER_STATE_START
The render state used when the data grid performs its first pass through its tag body.

See Also:
Constant Field Values

RENDER_STATE_CAPTION

public static final int RENDER_STATE_CAPTION
The render state used when the data grid is rendering the caption tag.

See Also:
Constant Field Values

RENDER_STATE_HEADER

public static final int RENDER_STATE_HEADER
The render state used when the data grid is rendering the header tag.

See Also:
Constant Field Values

RENDER_STATE_GRID

public static final int RENDER_STATE_GRID
The render state used when the data grid is rendering the data rows.

See Also:
Constant Field Values

RENDER_STATE_FOOTER

public static final int RENDER_STATE_FOOTER
The render state used when the data grid is rendering the footer.

See Also:
Constant Field Values

RENDER_STATE_END

public static final int RENDER_STATE_END
The render state used when the data grid has completed rendering.

See Also:
Constant Field Values
Constructor Detail

DataGridTagModel

public DataGridTagModel(String name,
                        DataGridConfig dataGridConfig,
                        JspContext jspContext)
Constructor used to build a DataGridTagModel.

Parameters:
name - the name of the data grid
dataGridConfig - the DataGridConfig object for a data grid
jspContext - the JspContext for the JSP in which the data grid's rendering started
Method Detail

getName

public String getName()
Accessor for the name of the data grid.

Returns:
the name of the data grid

getJspContext

public JspContext getJspContext()
Accessor for the JspContext for the JSP in which the grid started to render.

Returns:
the JspContext

getRenderState

public int getRenderState()

Accessor for the current render state. This should be used by clients that need to affect their behavior based on the data grid's current render state. This value will be one of:

Returns:
the current render state

changeRenderState

public void changeRenderState(int renderState)

Method that alters the data grid's current render to the new renderState. If the provided render state value is unknown, an IllegalStateException is thrown. The data grid cycles through its state in this order:

Parameters:
renderState - the DataGridTagModel's new render state
Throws:
IllegalStateException - if an invalid state is provided

getDataSet

public PagedDataSet getDataSet()
Accessor for the PagedDataSet that is used to render a data set in the grid.

Returns:
a PagedDataSet for the current data set

setDataSet

public void setDataSet(PagedDataSet dataSet)
Setter for the PagedDataSet object. In order to canonicalize the type used by the data grid to manipulate the data set, the PagedDataSet is used to navigate the data set.

Parameters:
dataSet - the data set

getPagerRenderer

public PagerRenderer getPagerRenderer()
Accessor for the PagerRenderer. This is the PagerRenderer instance that will be used to render the UI used to display the pager.

Returns:
the PagerRenderer for the data grid

setPagerRenderer

public void setPagerRenderer(PagerRenderer pagerRenderer)
Set the PagerRenderer used to render the paging UI for the data grid.

Parameters:
pagerRenderer - the PagerRenderer to use

getResourceProvider

public DataGridResourceProvider getResourceProvider()
Get the DataGridResourceProvider used to provide string messages, paths, etc during data grid rendering.

Returns:
the DataGridResourceProvider

setResourceProvider

public void setResourceProvider(DataGridResourceProvider resourceProvider)
Set the DataGridResourceProvider used to render the data grid.

Parameters:
resourceProvider - the new resource provider

isDisableDefaultPagerRendering

public boolean isDisableDefaultPagerRendering()
Check to see if the data grid will render its pager UI by default. The location for the default UI is controlled by the JSP tag doing the rendering.

Returns:
true if default rendering is enabled; false otherwise.

setDisableDefaultPagerRendering

public void setDisableDefaultPagerRendering(boolean disableDefaultPagerRendering)
Set a boolean to enable or disable rendering the pager UI by default. If true, the data grid rendering tags will produce the pager markup in some default location. If false the default pager rendering will be disabled. The default location is determined by the tags doing the rendering.

Parameters:
disableDefaultPagerRendering - boolean for enabling or disabling rendering the pager in the default location

isRenderRowGroups

public boolean isRenderRowGroups()

Get the flag for whether to render the data grid using HTML row groups. Row groups include the HTML thead, tbody, and tfoot tags. If row group rendering is enabled, the HTML produced by the data grid will be contained inside of these tags and rendered in the correct order in the produced HTML. More detail on row groups can be found here.

Returns:
true if row groups will be rendered; false otherwise

setRenderRowGroups

public void setRenderRowGroups(boolean renderRowGroups)
Set whether to render the data grid using HTML row groups. For more detail, see isRenderRowGroups().

Parameters:
renderRowGroups - true if rendering row groups; false otherwise

getTableRenderer

public TableRenderer getTableRenderer()
Get the instance of TableRenderer that is used to render HTML table markup for a data grid.

Returns:
the TableRenderer

setTableRenderer

public void setTableRenderer(TableRenderer tableRenderer)
Set the TableRenderer used to render HTML table markup for a data grid.

Parameters:
tableRenderer - the TableRenderer to use for rendering

getStyleModel

public StyleModel getStyleModel()
Get the StyleModel used to create style classes during data grid rendering.

Returns:
the StyleModel

setStyleModel

public void setStyleModel(StyleModel styleModel)
Set the StyleModel used to create style classes during data grid rendering.

Parameters:
styleModel - the StyleModel

getMessage

public String getMessage(String key)
Get a message given a resource string name key.

Parameters:
key - the message key
Returns:
the value of the message

formatMessage

public String formatMessage(String key,
                            Object[] args)
Format a message given a resource string name key and a set of formatting arguments args.

Parameters:
key - the message key
args - the arguments used when formatting the message
Returns:
the formatted message

addResourceOverride

public void addResourceOverride(String key,
                                String value)

This method provides support for overriding the messages available in the DataGridResourceProvider on a per-message basis. The key and value parameters here will override (or add) a message available via the DataGridResourceProvider without requiring an entire Java properties file or custom DataGridResourceProvider implementation.

Parameters:
key - the key of the message to override
value - the new value for the message key

getResourcePath

public String getResourcePath()

Get the resourrce path used when creating HTML image links during data grid rendering. The value of the default resource path is the HttpServletRequest.getContextPath() combined with the value of the data grid message stringn obtained with the key IDataGridMessageKeys.DATAGRID_RESOURCE_PATH.

Returns:
the string resource path

getSortImagePath

public String getSortImagePath(SortDirection sortDirection)

Get the image paths used for the given SortDirection. The image paths are discovered by using the following mapping.

Sort directionMessage key
SortDirection.ASCENDINGIDataGridMessageKeys.SORT_ASC_IMAGE_PATH
SortDirection.DESCENDINGIDataGridMessageKeys.SORT_DESC_IMAGE_PATH
SortDirection.NONEIDataGridMessageKeys.SORT_NONE_IMAGE_PATH
The value for the message is obtained by looking up a value in the DataGridResourceProvider obtained via getResourceProvider() using the message key in the table above.

Parameters:
sortDirection - the SortDirection used to lookup an image path
Returns:
the string image used to represent a sort direction graphically

getDefaultSortImagePath

public String getDefaultSortImagePath()
Get the default image path used when constructing links to sort images. This value is taken from the resource String available via the DataGridResourceProvider obtained using getResourceProvider() using the IDataGridMessageKeys.SORT_NONE_IMAGE_PATH key.

Returns:
the String path

renderPager

public void renderPager(AbstractRenderAppender appender)
Method used to render the data grid's pager UI into the given AbstractRenderAppender.

Parameters:
appender - the AbstractRenderAppender into which the pager will be rendered

getState

public DataGridState getState()
Accessor for obtaining the DataGridState object. This is a JavaBean property that can be accessed via an expression language in order to obtain access to the state information for the data grid stored in the returned object.

Returns:
the data grid's DataGridState

getUrlBuilder

public DataGridURLBuilder getUrlBuilder()
Accessor for obtaining the DataGridURLBuilder object. This is a JavaBean that can be accessed via an expression language in order to obtain access to the URL information for the data grid stored in the returned object.

Returns:
the data grid's DataGridURLBuilder

getCurrentIndex

public int getCurrentIndex()
Accessor for obtaining the current index in the data set. This value is a zero based count current item being rendered. For the array {"foo", "bar", "baz"}, the indices for each item would be 0, 1, and 2. This value does correspond to the index into an Object array or a list, but in an arbitrary Collection, the index is simply the number of items that appeared in the Collection before the current one.

Returns:
the current index

getCurrentItem

public Object getCurrentItem()
Accessor for obtaining the current item in the data set.

Returns:
the current item in the data set

getDataSource

public String getDataSource()
Accessor for obtaining the data source expression that was used to data bind to the data set.

Returns:
the String for the data source

nextDataItem

public Object nextDataItem()
Accessor for getting the next item in the data set.

Returns:
the next item in the data set. Note, depending on the data set, this item could be null.

hasNextDataItem

public boolean hasNextDataItem()
Accessor for determining if there is another item in the data set.

Returns:
true if there is a next item; false otherwise.