Object
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
DatabaseControl
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 SortFilterService.getQueryParamsMapWithSort(String, String)
could be available in an anchor that is rendered at the end of this request.
Object
SortFilterService
Field Summary |
public static final |
|
public static final |
|
public static final |
|
public static final int |
|
public static final int |
|
public static final int |
|
Method Summary |
public void |
|
public static |
|
public static |
|
public int |
|
public |
|
public static |
|
public int |
|
public |
|
public |
|
public |
|
public |
|
public int |
|
public boolean |
|
public boolean | |
public void |
|
public void | |
public void |
|
public |
|
public void |
|
Methods from class java.lang. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String
PRIMARY_KEY
SortFilterService.ROW_IDENTIFIER
instead.
public static final String
REQUEST_KEY
public static final String
ROW_IDENTIFIER
public static final int SORT_ASCENDING
public static final int SORT_DESCENDING
public static final int SORT_NONE
Method Detail |
public void addRowIdentifier(String
gridName,String
columnName,Object
value)
Add a row identifier which is accessible using the SortFilterService.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.
public staticString
decodeUniqueIdentifier(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.
public staticString
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.
public int getCurrentPage(String
gridName)
Get the current page for a specific grid.
publicDatabaseFilter
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.
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 staticFactory method to create aSortFilterService
getInstance(Object
object)
SortFilterService
object. Usually,
the object passed here is an HttpServletRequest
.
HttpServletRequest
SortFilterService
for use during the current request. public int getPageSize()
Get the default page size.
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 parameters publicMap
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.
Map
containing all of the current request's parameters and
a new parameter that sets the page for the given grid. publicMap
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:
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 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.
SortFilterService.SORT_ASCENDING
if the column is sorted in ascending order, SortFilterService.SORT_DESCENDING
if the column is sorted in descending order,
and SortFilterService.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.
true
if the column is filtered for the grid; false
otherwise. public boolean isSorted(String
gridName,String
columnName)
Check the sort state of a given column in a grid for the current request.
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.
public void resetCurrentPage(String
gridName)
Reset the current page of a specific grid. The page is reset to the first grid page.
public String
toString()
Utility method thath prints the current state of a SortFilterService
instance.
Object.toString()
String
representing the state
public void updateRowId(ServletRequest
request)
Update the row identifiers given the current request.