org.apache.wicket.markup.repeater
Class RefreshingView

java.lang.Object
  extended by org.apache.wicket.Component
      extended by org.apache.wicket.MarkupContainer
          extended by org.apache.wicket.markup.html.WebMarkupContainer
              extended by org.apache.wicket.markup.repeater.AbstractRepeater
                  extended by org.apache.wicket.markup.repeater.RepeatingView
                      extended by org.apache.wicket.markup.repeater.RefreshingView
All Implemented Interfaces:
java.io.Serializable, IClusterable, IConverterLocator
Direct Known Subclasses:
AbstractPageableView

public abstract class RefreshingView
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.

Author:
Igor Vaynberg (ivaynberg)
See Also:
RepeatingView, ModelIteratorAdapter, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.wicket.Component
Component.ComponentModelChange, Component.EnabledChange, Component.IVisitor, Component.VisibilityChange
 
Field Summary
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER
 
Constructor Summary
RefreshingView(java.lang.String id)
          Constructor
RefreshingView(java.lang.String id, IModel model)
          Constructor
 
Method Summary
protected  void addItems(java.util.Iterator items)
          Add items to the view.
protected abstract  java.util.Iterator getItemModels()
          Returns an iterator over models for items that will be added to this view
 IItemReuseStrategy getItemReuseStrategy()
           
 java.util.Iterator getItems()
           
protected  Item newItem(java.lang.String id, int index, IModel model)
          Factory method for Item container.
protected  IItemFactory newItemFactory()
          Create a new IItemFactory based upon the RefreshingView
protected  void onPopulate()
          Refresh the items in the view.
protected abstract  void populateItem(Item item)
          Populate the given Item container.
 RefreshingView setItemReuseStrategy(IItemReuseStrategy strategy)
          Sets the item reuse strategy.
 
Methods inherited from class org.apache.wicket.markup.repeater.RepeatingView
newChildId, renderIterator
 
Methods inherited from class org.apache.wicket.markup.repeater.AbstractRepeater
onBeforeRender, onRender, renderChild
 
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getMarkupType, getWebPage
 
Methods inherited from class org.apache.wicket.MarkupContainer
add, addOrReplace, autoAdd, autoAdd, contains, findMarkupStream, get, getAssociatedMarkupStream, getMarkupStream, hasAssociatedMarkup, internalAdd, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onComponentTagBody, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, setModel, size, toString, toString, visitChildren, visitChildren
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, callOnBeforeRenderIfNotVisible, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, continueToOriginalDestination, debug, detach, detachBehaviors, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getBehaviors, getBehaviors, getBehaviorsRawList, getClassRelativePath, getComponentBorder, getConverter, getConverter, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMarkupId, getMetaData, getModel, getModelComparator, getModelObject, getModelObjectAsString, getModelObjectAsString, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageFactory, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalAttach, internalDetach, internalOnAttach, internalOnDetach, internalOnModelChanged, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, newPage, newPage, onAfterRender, onAttach, onBeginRequest, onComponentTag, onDetach, onEndRequest, onModelChanged, onModelChanging, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderHead, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMetaData, setModelObject, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RefreshingView

public RefreshingView(java.lang.String id)
Constructor

Parameters:
id - component id

RefreshingView

public RefreshingView(java.lang.String id,
                      IModel model)
Constructor

Parameters:
id - component id
model - model
Method Detail

onPopulate

protected final void onPopulate()
Refresh the items in the view. Delegates the creation of items to the selected item reuse strategy

Overrides:
onPopulate in class RepeatingView
See Also:
AbstractRepeater.onPopulate()

newItemFactory

protected IItemFactory newItemFactory()
Create a new IItemFactory based upon the RefreshingView

Returns:
An Item factory that delegates to the RefreshingView

getItemModels

protected abstract java.util.Iterator getItemModels()
Returns an iterator over models for items that will be added to this view

Returns:
an iterator over models for items that will be added to this view

populateItem

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

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

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

Parameters:
item - The item to populate

newItem

protected Item newItem(java.lang.String id,
                       int index,
                       IModel model)
Factory method for Item container. Item containers are simple MarkupContainer used to aggregate the user added components for a row inside the view.

Parameters:
id - component id for the new data item
index - the index of the new data item
model - the model for the new data item
Returns:
DataItem created DataItem
See Also:
Item

getItems

public java.util.Iterator getItems()
Returns:
iterator over item instances that exist as children of this view

addItems

protected void addItems(java.util.Iterator items)
Add items to the view. Prior to this all items were removed so every request this function starts from a clean slate.

Parameters:
items - item instances to be added to this view

getItemReuseStrategy

public IItemReuseStrategy getItemReuseStrategy()
Returns:
currently set item reuse strategy. Defaults to DefaultItemReuseStrategy if none was set.
See Also:
DefaultItemReuseStrategy

setItemReuseStrategy

public RefreshingView setItemReuseStrategy(IItemReuseStrategy strategy)
Sets the item reuse strategy. This strategy controls the creation of Items.

Parameters:
strategy - item reuse strategy
Returns:
this for chaining
See Also:
IItemReuseStrategy


Copyright © 2004-2010 Apache Software Foundation. All Rights Reserved.