Class RefreshingView<T>
- java.lang.Object
-
- org.apache.wicket.Component
-
- org.apache.wicket.MarkupContainer
-
- org.apache.wicket.markup.html.WebMarkupContainer
-
- org.apache.wicket.markup.repeater.AbstractRepeater
-
- org.apache.wicket.markup.repeater.RepeatingView
-
- org.apache.wicket.markup.repeater.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:
AbstractPageableView
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()
andpopulateItem(Item)
methods. RefreshingView builds the items that will be rendered by looping over the models retrieved fromgetItemModels()
and calling thenewItem(String, int, IModel)
to generate the child item container followed by a call topopulateItem(Item)
to let the user populate the newly created item container with custom components.The provided
ModelIteratorAdapter
can make implementinggetItemModels()
easier if you have an iterator over item objects.- Author:
- Igor Vaynberg (ivaynberg)
- See Also:
RepeatingView
,ModelIteratorAdapter
, Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
-
-
Constructor Summary
Constructors Constructor Description RefreshingView(String id)
ConstructorRefreshingView(String id, IModel<?> model)
Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addItems(Iterator<Item<T>> items)
Add items to the view.protected abstract Iterator<IModel<T>>
getItemModels()
Returns an iterator over models for items that will be added to this viewIItemReuseStrategy
getItemReuseStrategy()
Iterator<Item<T>>
getItems()
protected Item<T>
newItem(String id, int index, IModel<T> model)
Factory method for Item container.protected IItemFactory<T>
newItemFactory()
Create a new IItemFactory based upon the RefreshingViewprotected void
onPopulate()
Refresh the items in the view.protected abstract void
populateItem(Item<T> item)
Populate the given Item container.RefreshingView<T>
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
dequeue, getMarkup, onBeforeRender, onRender, renderChild
-
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
-
Methods inherited from class org.apache.wicket.MarkupContainer
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onDetach, onInitialize, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildren
-
Methods inherited from class org.apache.wicket.Component
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMarkupTag, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onComponentTag, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
RefreshingView
public RefreshingView(String id)
Constructor- Parameters:
id
- component id
-
RefreshingView
public RefreshingView(String id, IModel<?> model)
Constructor- Parameters:
id
- component idmodel
- 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 classRepeatingView
- See Also:
AbstractRepeater.onPopulate()
-
newItemFactory
protected IItemFactory<T> newItemFactory()
Create a new IItemFactory based upon the RefreshingView- Returns:
- 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- Returns:
- 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"));
but:item.add(new Label("foo", "bar"));
- Parameters:
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.- Parameters:
id
- component id for the new data itemindex
- the index of the new data itemmodel
- the model for the new data item- Returns:
- DataItem created DataItem
- See Also:
Item
-
getItems
public Iterator<Item<T>> getItems()
- Returns:
- 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.- 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<T> setItemReuseStrategy(IItemReuseStrategy strategy)
Sets the item reuse strategy. This strategy controls the creation ofItem
s.- Parameters:
strategy
- item reuse strategy- Returns:
- this for chaining
- See Also:
IItemReuseStrategy
-
-