Class RefreshingView<T>

Type Parameters:
T - type of elements contained in the model's list
All Implemented Interfaces:
Serializable, Iterable<Component>, IEventSink, IEventSource, IFeedbackContributor, IConverterLocator, IMetadataContext<Serializable,Component>, IHeaderContributor, IRequestableComponent, IHierarchical<Component>, IClusterable
Direct Known Subclasses:

public abstract class RefreshingView<T> extends RepeatingView
An abstract repeater view that provides refreshing functionality to its subclasses. The view is refreshed every request, making it well suited for displaying dynamic data.

The view is populated by implementing getItemModels() and populateItem(Item) methods. RefreshingView builds the items that will be rendered by looping over the models retrieved from getItemModels() and calling the newItem(String, int, IModel) to generate the child item container followed by a call to populateItem(Item) to let the user populate the newly created item container with custom components.

The provided ModelIteratorAdapter can make implementing getItemModels() easier if you have an iterator over item objects.

Igor Vaynberg (ivaynberg)
See Also:
  • Constructor Details

  • Method Details

    • onPopulate

      protected final void onPopulate()
      Refresh the items in the view. Delegates the creation of items to the selected item reuse strategy
      onPopulate in class RepeatingView
      See Also:
    • newItemFactory

      Create a new IItemFactory based upon the RefreshingView
      An Item factory that delegates to the RefreshingView
    • getItemModels

      protected abstract Iterator<IModel<T>> getItemModels()
      Returns an iterator over models for items that will be added to this view
      an iterator over models for items that will be added to this view
    • populateItem

      protected abstract void populateItem(Item<T> item)
      Populate the given Item container.

      be careful to add any components to the item and not the view itself. So, don't do:

       add(new Label("foo", "bar"));
       item.add(new Label("foo", "bar"));

      item - The item to populate
    • newItem

      protected Item<T> newItem(String id, int index, IModel<T> model)
      Factory method for Item container. Item containers are simple MarkupContainer used to aggregate the user added components for a row inside the view.
      id - component id for the new data item
      index - the index of the new data item
      model - the model for the new data item
      DataItem created DataItem
      See Also:
    • getItems

      public Iterator<Item<T>> getItems()
      iterator over item instances that exist as children of this view
    • addItems

      protected void addItems(Iterator<Item<T>> items)
      Add items to the view. Prior to this all items were removed so every request this function starts from a clean slate.
      items - item instances to be added to this view
    • getItemReuseStrategy

      currently set item reuse strategy. Defaults to DefaultItemReuseStrategy if none was set.
      See Also:
    • setItemReuseStrategy

      Sets the item reuse strategy. This strategy controls the creation of Items.
      strategy - item reuse strategy
      this for chaining
      See Also: