E
- the generic type of the entities being queriedpublic abstract class BasePageHelper<E extends sirius.db.mixing.BaseEntity<?>,C extends sirius.db.mixing.query.constraints.Constraint,Q extends sirius.db.mixing.query.Query<Q,E,C>,B extends BasePageHelper<E,C,Q,B>> extends Object
WebContext
and create a resulting Page
which can be used to render a resulting table and filter box.Modifier and Type | Field and Description |
---|---|
protected Q |
baseQuery |
protected sirius.web.http.WebContext |
ctx |
protected static int |
DEFAULT_PAGE_SIZE |
protected List<sirius.kernel.commons.Tuple<sirius.web.controller.Facet,BiConsumer<sirius.web.controller.Facet,Q>>> |
facets |
protected int |
pageSize |
protected List<sirius.db.mixing.query.QueryField> |
searchFields |
Modifier | Constructor and Description |
---|---|
protected |
BasePageHelper(Q query) |
Modifier and Type | Method and Description |
---|---|
B |
addBooleanFacet(String name,
String title)
Adds a boolean based filter which permits to filter on boolean values.
|
B |
addFacet(sirius.web.controller.Facet facet,
BiConsumer<sirius.web.controller.Facet,Q> filter)
Adds a filter facet which a custom filter implementation.
|
B |
addFacet(sirius.web.controller.Facet facet,
BiConsumer<sirius.web.controller.Facet,Q> filter,
BiConsumer<sirius.web.controller.Facet,Q> itemsComputer)
Adds a filter facet with custom filter implementation and a custom item computer.
|
B |
addFilterFacet(sirius.web.controller.Facet facet)
Adds a filter facet which will show distinct values of the given property.
|
B |
addTimeFacet(String name,
String title,
sirius.db.mixing.DateRange... ranges)
Adds a time series based filter which permits to filter on certain time ranges.
|
protected void |
applyFacets(sirius.web.controller.Page<E> result) |
sirius.web.controller.Page<E> |
asPage()
Wraps the given data into a
Page which can be used to render a table, filterbox and support pagination. |
protected sirius.web.controller.Facet |
createTimeFacet(String name,
String title,
sirius.db.mixing.DateRange[] ranges) |
protected void |
enforcePaging(sirius.web.controller.Page<E> result,
List<E> items) |
protected List<E> |
executeQuery() |
protected void |
fillPage(sirius.kernel.commons.Watch w,
sirius.web.controller.Page<E> result,
List<E> items) |
protected void |
setupPaging(sirius.web.controller.Page<E> result) |
B |
withContext(sirius.web.http.WebContext ctx)
Attaches a web context to the helper, to fetch filter and pagination values from.
|
B |
withPageSize(int pageSize)
Specifies the number of items shown on the page that gets rendered using this pageHelper.
|
B |
withSearchFields(sirius.db.mixing.query.QueryField... searchFields)
Specifies one or more search fields which will be searched if a query
if given in the WebContext.
|
protected static final int DEFAULT_PAGE_SIZE
protected sirius.web.http.WebContext ctx
protected List<sirius.db.mixing.query.QueryField> searchFields
protected List<sirius.kernel.commons.Tuple<sirius.web.controller.Facet,BiConsumer<sirius.web.controller.Facet,Q extends sirius.db.mixing.query.Query<Q,E,C>>>> facets
protected int pageSize
protected BasePageHelper(Q query)
public B withContext(sirius.web.http.WebContext ctx)
ctx
- the request to attachpublic B withSearchFields(sirius.db.mixing.query.QueryField... searchFields)
searchFields
- the fields to search inpublic B addFilterFacet(sirius.web.controller.Facet facet)
facet
- the facet to addpublic B addFacet(sirius.web.controller.Facet facet, BiConsumer<sirius.web.controller.Facet,Q> filter)
facet
- the facet to addfilter
- the custom logic which determines how a filter value is applied to the query.public B addFacet(sirius.web.controller.Facet facet, BiConsumer<sirius.web.controller.Facet,Q> filter, BiConsumer<sirius.web.controller.Facet,Q> itemsComputer)
facet
- the facet to addfilter
- the custom logic which determines how a filter value is applied to the query.itemsComputer
- the custom logic which determines the list of items in the filterpublic B addTimeFacet(String name, String title, sirius.db.mixing.DateRange... ranges)
name
- the name of the field to filter ontitle
- the title of the filter shown to the userranges
- the ranges which are supported as filter valuesprotected sirius.web.controller.Facet createTimeFacet(String name, String title, sirius.db.mixing.DateRange[] ranges)
public B addBooleanFacet(String name, String title)
name
- the name of the field to filter ontitle
- the title of the filter shown to the userpublic B withPageSize(int pageSize)
pageSize
- the number of items shown per pagepublic sirius.web.controller.Page<E> asPage()
Page
which can be used to render a table, filterbox and support pagination.protected void fillPage(sirius.kernel.commons.Watch w, sirius.web.controller.Page<E> result, List<E> items)
protected void setupPaging(sirius.web.controller.Page<E> result)
protected void applyFacets(sirius.web.controller.Page<E> result)
Copyright © 2018. All rights reserved.