Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.hq.ui.taglib.display
Class TableTag

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by org.hyperic.hq.ui.taglib.display.TemplateTag
              extended by org.hyperic.hq.ui.taglib.display.TablePropertyTag
                  extended by org.hyperic.hq.ui.taglib.display.TableTag
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 class TableTag
extends TablePropertyTag

This tag takes a list of objects and creates a table to display those objects. With the help of column tags, you simply provide the name of properties (get Methods) that are called against the objects in your list that gets displayed [[reword that...]] This tag works very much like the struts iterator tag, most of the attributes have the same name and functionality as the struts tag. Simple Usage:

More Complete Usage:

Attributes:

name property scope length offset pageSize decorator HTML Pass-through Attributes There are a number of additional attributes that just get passed through to the underlying HTML table declaration. With the exception of the following few default values, if these attributes are not provided, they will not be displayed as part of the

tag. width - defaults to "100%" if not provided border - defaults to "0" if not provided cellspacing - defaults to "0" if not provided cellpadding - defaults to "2" if not provided align nowrapHeader background bgcolor frame height hspace rules summary vspace

See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable nextRow
           
protected  java.util.Hashtable previousRow
           
 
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
TableTag()
           
 
Method Summary
 void addColumn(ColumnTag obj)
          Called by interior column tags to help this tag figure out how it is supposed to display the information in the List it is supposed to display
protected  java.lang.String autoLink(java.lang.String data)
          This takes the string that is passed in, and "auto-links" it, it turns email addresses into hyperlinks, and also turns things that looks like URLs into hyperlinks as well.
 int doAfterBody()
          Make the next collection element available and loop, or finish the iterations if there are no more elements.
 int doEndTag()
          Draw the table.
 int doStartTag()
          When the tag starts, we just initialize some of our variables, and do a little bit of error checking to make sure that the user is not trying to give us parameters that we don't expect.
protected  void evaluateAttributes()
           
protected  java.lang.StringBuffer generateRow(java.lang.Object row, int rowcnt)
          Format the row as HTML.
protected  java.lang.String getTableAttributes()
          Takes all the table pass-through arguments and bundles them up as a string that gets tacked on to the end of the table tag declaration.
protected  java.lang.String getTableFooter()
          Generates table footer with links for export commands.
protected  java.lang.String getTableHeader()
          Generates the table header, including the first row of the table which displays the titles of the various columns.
 java.util.List getViewableData()
          This returns a list of all of the data that will be displayed on the page via the table tag.
protected  java.lang.String group(java.lang.String value, int group)
          This takes a cloumn value and grouping index as the argument.
protected  boolean isFirstIteration()
          Is this the first iteration?
protected  Decorator loadDecorator()
          If the user has specified a decorator, then this method takes care of creating the decorator (and checking to make sure it is a subclass of the TableDecorator object).
 java.lang.Object lookup(javax.servlet.jsp.PageContext pageContext, java.lang.String name, java.lang.String scope)
          This functionality is borrowed from struts, but I've removed some struts specific features so that this tag can be used both in a struts application, and outside of one.
 java.lang.Object lookup(javax.servlet.jsp.PageContext pageContext, java.lang.String name, java.lang.String property, java.lang.String scope, boolean useDecorator)
          This functionality is borrowed from struts, but I've removed some struts specific features so that this tag can be used both in a struts application, and outside of one.
 void release()
           
 void setFooter(java.lang.String string)
          Sets the content of the footer.
 void setProperty(java.lang.String name, java.lang.String value)
          Called by the setProperty tag to override some default behavior or text string.
protected  void sortDataIfNeeded(java.util.List viewableData)
          This method will sort the data in either ascending or decending order based on the user clicking on the column headers.
 
Methods inherited from class org.hyperic.hq.ui.taglib.display.TablePropertyTag
getAction, getAlign, getBackground, getBgcolor, getBorder, getCellpadding, getCellspacing, getDecorator, getDisplay, getEmptyMsg, getExport, getFrame, getHeight, getHspace, getIncludeTotals, getItems, getLength, getNowrapHeader, getOffset, getOrder, getOrderValue, getPage, getPageSize, getPageSizeValue, getPageValue, getParamId, getParamName, getParamProperty, getParamScope, getProperty, getRules, getScope, getSort, getSortValue, getStyleClass, getStyleId, getSummary, getVar, getVspace, getWidth, isLeftSidebar, isPadRows, isRightSidebar, setAction, setAlign, setBackground, setBgcolor, setBorder, setCellpadding, setCellspacing, setDecorator, setDisplay, setEmptyMsg, setExport, setFrame, setHeight, setHspace, setIncludeTotals, setItems, setLeftSidebar, setLength, setNowrapHeader, setOffset, setOrder, setOrderValue, setPadRows, setPage, setPageSize, setPageSizeValue, setPageValue, setParamId, setParamName, setParamProperty, setParamScope, setProperty, setRightSidebar, setRules, setScope, setSort, setSortValue, setStyleClass, setStyleId, setSummary, setVar, setVspace, setWidth
 
Methods inherited from class org.hyperic.hq.ui.taglib.display.TemplateTag
write, 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, 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

previousRow

protected java.util.Hashtable previousRow

nextRow

protected java.util.Hashtable nextRow
Constructor Detail

TableTag

public TableTag()
Method Detail

release

public void release()
Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class javax.servlet.jsp.tagext.BodyTagSupport

addColumn

public void addColumn(ColumnTag obj)
Called by interior column tags to help this tag figure out how it is supposed to display the information in the List it is supposed to display

Parameters:
obj - an internal tag describing a column in this tableview

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
When the tag starts, we just initialize some of our variables, and do a little bit of error checking to make sure that the user is not trying to give us parameters that we don't expect.

Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Returns:
value returned by super.doStartTag()
Throws:
javax.servlet.jsp.JspException

doAfterBody

public int doAfterBody()
                throws javax.servlet.jsp.JspException
Make the next collection element available and loop, or finish the iterations if there are no more elements.

Specified by:
doAfterBody in interface javax.servlet.jsp.tagext.IterationTag
Overrides:
doAfterBody in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException - if a JSP exception has occurred

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Draw the table. This is where everything happens, we figure out what values we are supposed to be showing, we figure out how we are supposed to be showing them, then we draw them.

Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException

getViewableData

public java.util.List getViewableData()
                               throws javax.servlet.jsp.JspException
This returns a list of all of the data that will be displayed on the page via the table tag. This might include just a subset of the total data in the list due to to paging being active, or the user asking us to just show a subset, etc...

The list that is returned from here is not the original list, but it does contain references to the same objects in the original list, so that means that we can sort and reorder the list, but we can't mess with the data objects in the list.

Throws:
javax.servlet.jsp.JspException

sortDataIfNeeded

protected void sortDataIfNeeded(java.util.List viewableData)
This method will sort the data in either ascending or decending order based on the user clicking on the column headers.

Parameters:
viewableData - The list passed into this mehtod will be sorted.

generateRow

protected java.lang.StringBuffer generateRow(java.lang.Object row,
                                             int rowcnt)
                                      throws javax.servlet.jsp.JspException
Format the row as HTML.

Parameters:
row - The list object to format as HTML.
Returns:
The object formatted as HTML.
Throws:
javax.servlet.jsp.JspException

getTableHeader

protected java.lang.String getTableHeader()
                                   throws javax.servlet.jsp.JspException
Generates the table header, including the first row of the table which displays the titles of the various columns.

Returns:
Table header in HTML format
Throws:
javax.servlet.jsp.JspException

getTableFooter

protected java.lang.String getTableFooter()
                                   throws javax.servlet.jsp.JspException
Generates table footer with links for export commands.

Returns:
HTML formatted table footer
Throws:
javax.servlet.jsp.JspException

group

protected java.lang.String group(java.lang.String value,
                                 int group)
This takes a cloumn value and grouping index as the argument. It then groups the column and returns the appropritate string back to the caller.


getTableAttributes

protected java.lang.String getTableAttributes()
Takes all the table pass-through arguments and bundles them up as a string that gets tacked on to the end of the table tag declaration.

Note that we override some default behavior, specifically:

width defaults to 100% if not provided border defaults to 0 if not provided cellspacing defaults to 1 if not provided cellpadding defaults to 2 if not provided


lookup

public java.lang.Object lookup(javax.servlet.jsp.PageContext pageContext,
                               java.lang.String name,
                               java.lang.String scope)
                        throws javax.servlet.jsp.JspException
This functionality is borrowed from struts, but I've removed some struts specific features so that this tag can be used both in a struts application, and outside of one. Locate and return the specified bean, from an optionally specified scope, in the specified page context. If no such bean is found, return null instead.

Parameters:
pageContext - Page context to be searched
name - Name of the bean to be retrieved
scope - Scope to be searched (page, request, session, application) or null to use findAttribute() instead
Throws:
javax.servlet.jsp.JspException - if an invalid scope name is requested

lookup

public java.lang.Object lookup(javax.servlet.jsp.PageContext pageContext,
                               java.lang.String name,
                               java.lang.String property,
                               java.lang.String scope,
                               boolean useDecorator)
                        throws javax.servlet.jsp.JspException
This functionality is borrowed from struts, but I've removed some struts specific features so that this tag can be used both in a struts application, and outside of one. Locate and return the specified property of the specified bean, from an optionally specified scope, in the specified page context.

Parameters:
pageContext - Page context to be searched
name - Name of the bean to be retrieved
property - Name of the property to be retrieved, or null to retrieve the bean itself
scope - Scope to be searched (page, request, session, application) or null to use findAttribute() instead
Throws:
javax.servlet.jsp.JspException - if an invalid scope name is requested
javax.servlet.jsp.JspException - if the specified bean is not found
javax.servlet.jsp.JspException - if accessing this property causes an IllegalAccessException, IllegalArgumentException, InvocationTargetException, or NoSuchMethodException

loadDecorator

protected Decorator loadDecorator()
                           throws javax.servlet.jsp.JspException
If the user has specified a decorator, then this method takes care of creating the decorator (and checking to make sure it is a subclass of the TableDecorator object). If there are any problems loading the decorator then this will throw a JspException which will get propogated up the page.

Throws:
javax.servlet.jsp.JspException

autoLink

protected java.lang.String autoLink(java.lang.String data)
This takes the string that is passed in, and "auto-links" it, it turns email addresses into hyperlinks, and also turns things that looks like URLs into hyperlinks as well. The rules are currently very basic, In Perl regex lingo... Email: \b\S+\@[^\@\s]+\b URL: (http|https|ftp)://\S+\b I'm doing this via brute-force since I don't want to be dependent on a third party regex package.


setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Called by the setProperty tag to override some default behavior or text string.


setFooter

public void setFooter(java.lang.String string)
Sets the content of the footer. Called by a nested footer tag.

Parameters:
string - footer content

isFirstIteration

protected boolean isFirstIteration()
Is this the first iteration?

Returns:
boolean true if this is the first iteration

evaluateAttributes

protected void evaluateAttributes()
                           throws javax.servlet.jsp.JspTagException
Throws:
javax.servlet.jsp.JspTagException

Hyperic HQ Plugin API v. 4.4.0.2

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.