Module org.apache.wicket.core
Class ReuseIfModelsEqualStrategy
java.lang.Object
org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy
- All Implemented Interfaces:
Serializable
,IItemReuseStrategy
,IClusterable
Reuse strategy that will reuse an old item if its model is equal to a model inside the newModels
iterator. Useful when state needs to be kept across requests for as long as the item is visible
within the view.
Notice that the model and not the model object needs to implement the
Object.equals(Object)
and Object.hashCode()
methods. Most of the time it is a good idea to
forward the calls to the object, however if a detachable model is used it is often enough to
compare an identifier for the object the models are pointing to ( this saves the model from loading the
object).
- Author:
- Igor Vaynberg (ivaynberg)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic IItemReuseStrategy
Returns an iterator over items that will be added to the view.
-
Constructor Details
-
ReuseIfModelsEqualStrategy
public ReuseIfModelsEqualStrategy()
-
-
Method Details
-
getInstance
- Returns:
- static instance
-
getItems
public <T> Iterator<Item<T>> getItems(IItemFactory<T> factory, Iterator<IModel<T>> newModels, Iterator<Item<T>> existingItems) Description copied from interface:IItemReuseStrategy
Returns an iterator over items that will be added to the view. The iterator needs to return all the items because the old ones are removed prior to the new ones added.- Specified by:
getItems
in interfaceIItemReuseStrategy
- Type Parameters:
T
- type of Item- Parameters:
factory
- implementation of IItemFactorynewModels
- iterator over models for itemsexistingItems
- iterator over child items- Returns:
- iterator over items that will be added after all the old items are moved.
- See Also:
-