Ordering Collections
By default, the resources in a collection have an arbitrary sequence and no special order. If you want to explicitly specify an order, you can:
- Set the ordering of the collection to manual with the setOrderType() method offered by the ICollection interface
- Use the methods of IReorderList to change the sequence of the resources in the collection
The UML diagram shows the main classes and interfaces involved in the ordering of collections.

Interfaces and Classes
| Interface or Class | Purpose |
|---|---|
|
IReorderList |
Offers methods to reposition resources. The methods require an IPositioning object that stores the new position of a resource. |
|
IPositioning |
Stores the name of the resource that is to be repositioned and references the IPosition object that contains the target position. |
|
IPosition , |
A container for the target position of a resource. The target position is specified using the definitions provided by com.sapportals.wcm.repository.enums.OrderPosition :
|
Setting Ordering for a Collection
To enable the resources in a collection to be ordered, you first set the ordering of the collection to manual:
ICollection coll = …; coll.setOrderType(OrderType.MANUAL);
If a collection does not support ordering, the exception NotSupportedException is thrown.
Repositioning Resources
Once ordering is set to manual, you can reposition the resources as required. The code extract shows how a collection with the children 1st, 2nd, 3rd, 4th (ordered in this sequence) is reordered to 4th, 3rd, 1st, 2nd. The ReorderList.add() method repositions the resources according to the information provided by the Positioning object that is passed to the method as an argument. The IPositioning object contains the name of the resource involved and its new position.
IReorderList reordering = new ReorderList();
reordering.add(
new Positioning("4th", new Position.createFirstPosition())
);
reordering.add(
new Positioning("1st", new Position.createLastPosition())
);
reordering.add(
new Positioning("2nd", new Position("1st", OrderPosition.BEFORE))
);
reordering.add(
new Positioning("3rd", new Position("4th", OrderPosition.AFTER))
);
orderedCollection.reorder(reordering);