wicket.extensions.markup.html.repeater.refreshing
Class RefreshingView

java.lang.Object
  extended by wicket.Component
      extended by wicket.MarkupContainer
          extended by wicket.markup.html.WebMarkupContainer
              extended by wicket.extensions.markup.html.repeater.RepeatingView
                  extended by wicket.extensions.markup.html.repeater.refreshing.RefreshingView
All Implemented Interfaces:
java.io.Serializable
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 wicket.Component
wicket.Component.ComponentModelChange, wicket.Component.EnabledChange, wicket.Component.IVisitor, wicket.Component.VisibilityChange
 
Field Summary
 
Fields inherited from class 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, wicket.model.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  void internalOnAttach()
          Refresh the items in the view.
protected  Item newItem(java.lang.String id, int index, wicket.model.IModel model)
          Factory method for Item container.
protected abstract  void populateItem(Item item)
          Populate the given Item container.
 RefreshingView setItemReuseStrategy(IItemReuseStrategy strategy)
          Sets the item reuse strategy.
 
Methods inherited from class wicket.extensions.markup.html.repeater.RepeatingView
newChildId, onRender, renderChild, renderIterator
 
Methods inherited from class wicket.markup.html.WebMarkupContainer
getMarkupType, getWebPage
 
Methods inherited from class wicket.MarkupContainer
add, autoAdd, contains, findMarkupStream, get, getAssociatedMarkupStream, getMarkupStream, internalAdd, internalAttach, internalDetach, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onComponentTagBody, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, setModel, size, toString, toString, visitChildren, visitChildren
 
Methods inherited from class wicket.Component
add, addStateChange, checkComponentTag, checkComponentTagAttribute, continueToOriginalDestination, debug, detachBehaviors, detachModel, detachModels, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getApplicationPages, getApplicationSettings, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMetaData, getModel, getModelComparator, getModelObject, getModelObjectAsString, getOutputMarkupId, getPage, getPageFactory, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getString, getString, getString, getStyle, getVariation, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnDetach, internalOnModelChanged, isActionAuthorized, isAncestorOf, isBehaviorAccepted, isEnableAllowed, isEnabled, isHeadRendered, isIgnoreAttributeModifier, isRenderAllowed, isVersioned, isVisible, isVisibleInHierarchy, modelChanged, modelChanging, newPage, newPage, onAfterRender, onAttach, onBeforeRender, onBeginRequest, onComponentTag, onDetach, onEndRequest, onModelChanged, onModelChanging, onRender, redirectToInterceptPage, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderedBehaviors, renderHead, replaceComponentTagBody, replaceWith, resetHeadRendered, sameRootModel, sameRootModel, setAuto, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMetaData, setModelObject, setOutputMarkupId, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisible, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn
 
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,
                      wicket.model.IModel model)
Constructor

Parameters:
id - component id
model - model
Method Detail

internalOnAttach

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

Overrides:
internalOnAttach in class wicket.Component

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,
                       wicket.model.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-2008 Wicket developers. All Rights Reserved.