A bean providing a generic representation for a tabular result set
which may wrap a variety of RepositoryResults. Intended for use
with the genlist.jsp for generating table forms.
Using bean-style accessors so we can use
but I still don't see what the great advantage of that is...
setSortOrder(java.lang.String order)
Set the sort order.
void
setSortURL(java.lang.String url)
Set the URL that we will POST to when one of the sort "buttons" is hit.
void
setSortURLParams(java.lang.String params)
Set the URL parameters that will be added to the sortURL along with
the sort column and order
The parameters must be URLEncoded using something like
com.waveset.util.URLUTF8Encoder.encode()
Internal descriptor objects for each column.
We could expose these and shift some of the Table methods
to Column methods, but given that there aren't that many
Column properties, it feels simpler to keep this hidden.
Get the link URL for the form.
This will be the same as the post URL if no link URL has
been specified.
getLinkColumn
public int getLinkColumn()
Get the column number (starts at 0) that will be used for placing
the links defined by setLinkURL
getSortURL
public java.lang.String getSortURL()
Get the sort URL for the form.
If this isn't set, we default to the postURL.
getSortURLParams
public java.lang.String getSortURLParams()
Get the sort URL parameters for the form.
If this isn't set, we return an empty string
getColumnCount
public int getColumnCount()
Return the number of columns.
getRowCount
public int getRowCount()
Return the number of rows.
getRowHasCheckbox
public boolean getRowHasCheckbox(int r)
Return whether this row should generate a check box
getRowNeedsLink
public boolean getRowNeedsLink(int r)
Return whether this row should have a link in the _linkColumn column
If the rows have not been set for the table or the specified row
is out of bounds, then return the value of Table._generateLinks.
getRowTypeName
public java.lang.String getRowTypeName(int r)
Set the type name string for the row. This is used to generate the
name string of the checkbox (defaults to "select")
setRowHasCheckbox
public void setRowHasCheckbox(int r,
boolean hasCheckbox)
Set whether this row should generate a check box
setRowTypeName
public void setRowTypeName(int r,
java.lang.String typeName)
Set this row's datatype (stored as string in checkbox name)
getSortColumn
public java.lang.String getSortColumn()
Return the sort column name.
If the column is null, it defaults to the name of the
first column. getSortColumn should always return a non null value
to keep the .jsp from crashing.
getSortOrder
public java.lang.String getSortOrder()
Return the sort order.
Returns either "ASC" or "DESC". This is what Thought Interactive
coded for, it probably could be a simple boolean.
getColumnName
public java.lang.String getColumnName(int c)
Return the column name, for the title strip.
getColumnLabel
public java.lang.String getColumnLabel(int c)
Return the column label, for the title strip.
getColumnNameNoColon
public java.lang.String getColumnNameNoColon(int c)
getColumnIsWrap
public boolean getColumnIsWrap(int c)
implementsToHTML
public static java.lang.reflect.Method implementsToHTML(java.lang.Object o)
Determines if an object contains a toHTML method that takes
no arguments and returns a String
getCellHtml
public java.lang.String getCellHtml(RequestState req,
int r,
int c)
Return the cell representation in HTML.
getButtonCount
public int getButtonCount()
Return the number of buttons.
getTopButtonCount
public int getTopButtonCount()
getButtonHtml
public java.lang.String getButtonHtml(RequestState req,
int b,
Session session)
Returns the HTML representation of a button. If the button class
implements the toHTML method, then it will be used to generate the HTML.
Otherwise a generic button of the form
will be generated.
getButtonHtml
public java.lang.String getButtonHtml(RequestState req,
int b,
boolean topButton,
Session session)
getButtonName
public java.lang.String getButtonName(int b)
Return the display name of a button.
getTopButtonName
public java.lang.String getTopButtonName(int b)
Return the display name of a button.
getButtonValue
public java.lang.String getButtonValue(int b)
Return the form value when this button is selected.
getTopButtonValue
public java.lang.String getTopButtonValue(int b)
getSelectValue
public java.lang.String getSelectValue(int row)
Return the value to assign to the checkbox form item
in a mult-select table.
The value is the value of the _rowKey attribute of the Row inner
class. If this is not set, then the first column of the row is
used.
It may be overridden by a subclass if necessary.
isMultiSelect
public boolean isMultiSelect()
Returns true if this is designated as a multi-select table.
This normally results in the generation of a checkbox column.
isGenerateLinks
public boolean isGenerateLinks()
Returns true if the table will be generated with links
in the column specified by _linkColumn (defaults to 0).
getHiddenFormData
public java.util.Hashtable getHiddenFormData()
get the optional hidden form data
Each item in this hash table will be represented as
getError
public java.lang.String getError()
Get an optional error message for this table.
This will normally be rendered in some obvious way at the
top of the table.
getMessage
public java.lang.String getMessage()
Get the optional information message.
getParameter
public java.lang.String getParameter(javax.servlet.ServletRequest r,
java.lang.String name)
Return the value of a parameter, converting empty strings
to null.
Trim whitespace from both ends.
This is the same as EditForm.getParameter() and should be moved to some
common place.
encodeURLParameter
public static java.lang.String encodeURLParameter(java.lang.String name,
java.lang.String value)
A helper to take two names of parameters that may have null
values. Encode them in the URL. If the name turns out to be null, return an empty string.
This is a bit of a kludge, but I'm trying to keep the type language
simple. We need to have a way to specify what we want in the table.
Most of the time its a list of one type of PersistentObject,
with no filtering. Each type may have a different set of columns.
Sometimes the columns are dependent on the combination of type
and operation, e.g. "create role" may build a different table
than "delete role".
Further each table may have a set of buttons that will vary
depending on the operation.
A more flexible language for specifying all these options
may one day be required, but at the moment, its ok to hard-wire
table-building semantics to a few type symbols. See
the generation() method for what actually happens for each type.
Should we error here if the type is wrong, build an empty table,
or build a table with some recognizable error text?
setPostURL
public void setPostURL(java.lang.String url)
Set the URL that we will POST to when the generated form
is submitted. The URL is expected to have already been
processed with encodeURL() if necessary.
setLinkURL
public void setLinkURL(java.lang.String url)
Set the URL that we will goto when a link is selected.
This defaults to the postURL, unless explicitly specified.
setLinkColumn
public void setLinkColumn(int col)
Set the column number (starts at 0) that will be used for placing
the links defined by setLinkURL
setSortURL
public void setSortURL(java.lang.String url)
Set the URL that we will POST to when one of the sort "buttons" is hit.
setSortURLParams
public void setSortURLParams(java.lang.String params)
Set the URL parameters that will be added to the sortURL along with
the sort column and order
The parameters must be URLEncoded using something like
com.waveset.util.URLUTF8Encoder.encode()
public void setSubTitle(java.lang.String subTitle)
setSortColumn
public void setSortColumn(java.lang.String name)
Set the sort column.
The column can be null here in which case getSortColumn will
default to the name of the first column.
What should we do if the column name is wrong?
setGenerateLinks
public void setGenerateLinks(boolean b)
Set the link generation option.
If true, the table will be generated with the first column
values being links to the url specified in _linkURL or _postURL.
setSortOrder
public void setSortOrder(java.lang.String order)
Set the sort order.
This is really just a boolean, but its being exposed as a string.
Not sure if that's really necessary, but its the way Thought
Interactive was doing it.
Internally we recognize "DESC" as descending and anything
else is considered to be ascending. getSortOrder will
return "ASC" for ascending. The default is ascending.