Copyright© 2008-2026 Sitevision AB, all rights reserved.
@Requireable(value="SortBuilder") public interface SortBuilder extends Builder<Sort>
Builder for creating a Sort component with specific behaviour.
SortBuilder has one mandatory attribute:
Using the SortBuilder is pretty straightforward, if you remember that it is stateful. Conceptually you would typically use it like this:
When you have built a Sort instance, you can re-use the SortBuilder to build more instances. Typically like:
Example of how this strategy could be implemented in sever-side Javascript:
// Get the factory and the builder
var searchFactory = require('SearchFactory'),
sortBuilder = searchFactory.getSortBuilder(),
searchSortField,
updatedDescSort,
nameAscSort;
// Create a Sort
searchSortField = searchFactory.getSearchSortField('lastpublished', false);
updatedDescSort = sortBuilder.addSortField(searchSortField).build();
// Re-use the builder to create another Sort
searchSortField = searchFactory.getSearchSortField('name.sortable', true);
nameAscSort = sortBuilder.clearSortFields().addSortField(searchSortField).build();
Example of how this strategy could be implemented in Velocity:
## Get the factory and the builder
#set ($searchFactory = $sitevisionUtils.searchFactory)
#set ($sortBuilder = $searchFactory.sortBuilder)
## Create a Sort
#set ($searchSortField = $searchFactory.getSearchSortField('lastpublished', false))
#set ($updatedDescSort = $sortBuilder.addSortField($searchSortField).build())
## Re-use the builder to create another Sort
#set ($searchSortField = $searchFactory.getSearchSortField('name.sortable', true))
#set ($nameAscSort = $sortBuilder.clearSortFields().addSortField($searchSortField).build())
Tip! The Builder interface documentation contains
more information about Builders and how to work with them!
An instance of the Sitevision class implementing this interface can be obtained via
SearchFactory.getSortBuilder().
See SearchFactory for how to obtain an instance of the SearchFactory interface.
| Modifier and Type | Method and Description |
|---|---|
SortBuilder |
addSortField(SearchSortField aSearchSortField)
Adds a sort field.
|
Sort |
build()
Creates a Sort component instance using currently specified state/behaviour.
|
SortBuilder |
clearSortFields()
Removes all previously added sort fields.
|
SortBuilder addSortField(SearchSortField aSearchSortField)
aSearchSortField - a sort field, a null value is ignoredSortBuilder clearSortFields()
Sort build() throws IllegalStateException
build in interface Builder<Sort>IllegalStateException - if no sort fields are addedSitevision - Content Management Made Easy
Sitevision is an advanced Java enterprise portal product that implements Java Content Repository (JSR 283).
Copyright© 2008-2026 Sitevision AB, all rights reserved.