|
BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bea.wlw.netui.tags.databinding.SortFilterService
public final class SortFilterService
The SortFilterService
is used to keep track of sorts and
filters query parameters that are stored on the URL. These terms are
used to create a DatabaseFilter
which can be passed to a
JdbcControl
to parameterize a SQL query.
The SortFilterService can be used as a storage location for parameters that need to be stored on the URL but may not be encoded in every anchor on every page in a Java Page Flow.
The SortFilterService
is used to encode several bits of
state for a specific grid onto the URL including:
name
attribute. Multiple grids that may have parameters
on the URL at the same time should have unique names.
In general, the methods on this class are used to manipulate the query parameters
on URLs given the query parameters on the current request. Starting
with the request's parameter map, additional parameters may be added or
removed in order to build a map of values that can be attached to a given
anchor or form that will render as the result of the current request. For example,
a sort added to a column using the getQueryParamsMapWithSort(String, String)
could be available in an anchor that is rendered at the end of this request.
Field Summary | |
---|---|
static String |
PRIMARY_KEY
Deprecated. |
static String |
REQUEST_KEY
Key used to store a SortFilterSerivce object in the request. |
static String |
ROW_IDENTIFIER
The request key for a row identifier. |
static int |
SORT_ASCENDING
Constant representing an ascending sort applied to a column. |
static int |
SORT_DESCENDING
Constant representing a descending sort applied to a column. |
static int |
SORT_NONE
Constant representing no sorts applied to a column. |
Method Summary | |
---|---|
void |
addRowIdentifier(String gridName,
String columnName,
Object value)
Add a row identifier which is accessible using the getRowIdQueryParamsMap()
method. |
static String |
decodeUniqueIdentifier(javax.servlet.http.HttpServletRequest request,
String gridName,
String columnName)
Decode a value from the given request's query parameters. |
static String |
encodeUniqueIdentifier(String gridName,
String columnName,
Object columnValue)
Encode a grid/column value constraint. |
int |
getCurrentPage(String gridName)
Get the current page for a specific grid. |
com.bea.control.DatabaseFilter |
getDatabaseFilter(String gridName)
Gets a DatabaseFilter object that contains the sorts and
filters on the current request's URL. |
static SortFilterService |
getInstance(Object object)
Factory method to create a SortFilterService object. |
int |
getPageSize()
Get the default page size. |
Map |
getQueryParamsMap()
Get a Map of the query parameters that are on the current URL. |
Map |
getQueryParamsMapWithPage(String gridName,
int page)
Get a Map of query parameters that contains the request's
parameters and a new parameter that sets the current page
for the grid named gridName . |
Map |
getQueryParamsMapWithSort(String gridName,
String columnName)
Get a Map of query parameters that contains the request's
parameters and a new parameter that sets a new sort on some column
of a grid. |
static String |
getQueryParamsStringOmitFilter(String prefix,
String queryStr,
String gridName,
String columnName,
String encoding)
Internal method used to build a URL that contains all sorts / filters / pages / other parameters on the URL excluding those related to a particular grid or grid/column. |
Map |
getRowIdQueryParamsMap()
Get the query params map that contains only the row identifiers that should be encoded on the URL. |
int |
getSortDirection(String gridName,
String columnName)
Get the sort direction of a column in a grid. |
boolean |
isFiltered(String gridName,
String columnName)
Check the filter state of a given column in a grid for the current request. |
boolean |
isSorted(String gridName,
String columnName)
Check the sort state of a given column in a grid for the current request. |
void |
reset()
Clears all query information including the current page, sorts, and filters for all grid names that are on the URL. |
void |
reset(String gridName)
Clears the current page, sorts, and filters for the grid named gridName . |
void |
resetCurrentPage(String gridName)
Reset the current page of a specific grid. |
String |
toString()
Utility method thath prints the current state of a SortFilterService
instance. |
void |
updateRowId(javax.servlet.ServletRequest request)
Update the row identifiers given the current request. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String REQUEST_KEY
public static final int SORT_NONE
public static final int SORT_ASCENDING
public static final int SORT_DESCENDING
public static final String ROW_IDENTIFIER
public static final String PRIMARY_KEY
ROW_IDENTIFIER
instead.
Method Detail |
---|
public static SortFilterService getInstance(Object object)
SortFilterService
object. Usually,
the object passed here is an HttpServletRequest
.
object
- the object from which to create the SortFilterService, usually the HttpServletRequest
SortFilterService
for use during the current request.
IllegalArgumentException
- if the object
parameter is null or is not a valid type from
which to create a SortFilterService
.public com.bea.control.DatabaseFilter getDatabaseFilter(String gridName)
Gets a DatabaseFilter
object that contains the sorts and
filters on the current request's URL.
The gridName
is used to locate specific URL parameters that
are associated with a particular Grid tag.
gridName
- the name of a grid on the page
DatabaseFilter
object that can be
passed to a DatabaesControl instance to receive a sorted and
filtered query result. Returns null if the gridName is null.public Map getQueryParamsMap()
Get a Map
of the query parameters that are on the current URL.
In general, this method is used to pass these parameters from
page to page on an anchor or inside of a form.
Map
of the current query parameterspublic Map getQueryParamsMapWithPage(String gridName, int page)
Get a Map
of query parameters that contains the request's
parameters and a new parameter that sets the current page
for the grid named gridName
.
If the grid specified here already has a current page query parameter, it is replaced with the new value.
gridName
- the name of the grid for which to set the current pagepage
- the page to display
Map
containing all of the current request's parameters and
a new parameter that sets the page for the given grid.public Map getQueryParamsMapWithSort(String gridName, String columnName)
Get a Map
of query parameters that contains the request's
parameters and a new parameter that sets a new sort on some column
of a grid.
The criteria for creating a sort are these:
gridName
- the name of the grid for which to add a sortcolumnName
- the name of the column to sort
Map
containing all of the current request's parameters and
a new parameter that sorts the grid on the given column.public Map getRowIdQueryParamsMap()
Get the query params map that contains only the row identifiers that should be encoded on the URL.
Map
that contains the query parameters which contain
the row identifiers that uniquely represent a row in a data set.public static String getQueryParamsStringOmitFilter(String prefix, String queryStr, String gridName, String columnName, String encoding)
Internal method used to build a URL that contains all sorts / filters / pages / other parameters on the URL excluding those related to a particular grid or grid/column. If the columnName is null, the returned query parameters string will clear all filters for a grid. If the columnName is null, the returned query parameters string will clear only filters on the given column.
prefix
- any prefix associated with the filter keyqueryStr
- the current query stringgridName
- the name of the grid whose filters to removecolumnName
- the name of a column whose filters to removeencoding
- the encoding of the requesting page
public void updateRowId(javax.servlet.ServletRequest request)
Update the row identifiers given the current request.
request
- the current request object
IllegalStateException
- if the request object is null or is not an HttpServletRequest
public void reset()
Clears all query information including the current page, sorts, and filters for all grid names that are on the URL. Future calls to methods that return query parameter maps will not contain any of these parameters from the current request.
public void reset(String gridName)
Clears the current page, sorts, and filters
for the grid named gridName
. This will
leave all pages, sorts, and filters for all other
grid names.
gridName
- the name of the grid whose current page,
sorts, and filters to reset.public void resetCurrentPage(String gridName)
Reset the current page of a specific grid. The page is reset to the first grid page.
gridName
- the name of the grid whose page to resetpublic int getCurrentPage(String gridName)
Get the current page for a specific grid.
gridName
- the name of a grid whose current page may appear in the current query parameters
public int getPageSize()
Get the default page size.
public boolean isSorted(String gridName, String columnName)
Check the sort state of a given column in a grid for the current request.
gridName
- the name of the grid whose column to checkcolumnName
- the name of the column
public int getSortDirection(String gridName, String columnName)
Get the sort direction of a column in a grid. This method checks the current request's parameters and returns an identifier for the sort direction of the column.
gridName
- the name of the grid whose column to checkcolumnName
- the name of the column
SORT_ASCENDING
if the column is sorted in ascending order, SORT_DESCENDING
if the column is sorted in descending order,
and SORT_NONE
if the column is not sorted.public boolean isFiltered(String gridName, String columnName)
Check the filter state of a given column in a grid for the current request.
gridName
- the name of the grid whose column to checkcolumnName
- the name of the column
true
if the column is filtered for the grid; false
otherwise.public static String encodeUniqueIdentifier(String gridName, String columnName, Object columnValue)
Encode a grid/column value constraint. This method formats the grid/column/value group into a syntax that can be used as the value of a query parameter on a URL.
gridName
- the grid name for the encoded identifiercolumnName
- the column name for the encoded identifercolumnValue
- the value to encode
public static String decodeUniqueIdentifier(javax.servlet.http.HttpServletRequest request, String gridName, String columnName)
Decode a value from the given request's query parameters. If the grid and column names are present in the row identifiers in the query parameters, this returns a String representation of the value's constraint.
request
- the request from which to find the unique identifiergridName
- the name of the grid whose unique identifiers to checkcolumnName
- the name of the column whose constraint value to find
public void addRowIdentifier(String gridName, String columnName, Object value)
Add a row identifier which is accessible using the getRowIdQueryParamsMap()
method. Row identifiers added for a particular grid name can be used in an
Anchor or a Form to select a particular row to display on the next page.
gridName
- the name of the grid to which the row identifier is scopedcolumnName
- the name of the column that the identifier constrainsvalue
- the value of the constraint on the row identifier.public String toString()
Utility method thath prints the current state of a SortFilterService
instance.
toString
in class Object
String
representing the state
|
BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |