Class Fragment
- java.lang.Object
-
- org.apache.wicket.Component
-
- org.apache.wicket.MarkupContainer
-
- org.apache.wicket.markup.html.WebMarkupContainer
-
- org.apache.wicket.markup.html.panel.Fragment
-
- All Implemented Interfaces:
Serializable
,Iterable<Component>
,IEventSink
,IEventSource
,IFeedbackContributor
,IConverterLocator
,IMetadataContext<Serializable,Component>
,IQueueRegion
,IHeaderContributor
,IRequestableComponent
,IHierarchical<Component>
,IClusterable
public class Fragment extends WebMarkupContainer implements IQueueRegion
Usually you either have a markup file or a xml tag with wicket:id="myComponent" to associate markup with a component. However in some use cases, especially when working with small panels it is a bit awkward to maintain tiny pieces of markup in plenty of panel markup files. Use cases are for example list views where list items are different depending on a state.Fragments provide a means to maintain the panels tiny piece of markup. Since it can be anywhere, the component whose markup contains the fragment's markup must be provided (markup provider).
<span wicket:id="myPanel">Example input (will be removed)</span> <wicket:fragment wicket:id="frag1">panel 1</wicket:fragment> <wicket:fragment wicket:id="frag2">panel 2</wicket:fragment>
add(new Fragment("myPanel1", "frag1", myPage);
- Author:
- Juergen Donnerstag
- See Also:
- 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 Fragment(String id, String markupId, MarkupContainer markupProvider)
Constructor.Fragment(String id, String markupId, MarkupContainer markupProvider, IModel<?> model)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IMarkupFragment
chooseMarkup(MarkupContainer provider)
Get the markup stream which shall be used to search for the fragmentString
getAssociatedMarkupId()
DequeueContext
newDequeueContext()
Creates a newDequeueContext
that will be used to dequeue children of this region.protected IMarkupSourcingStrategy
newMarkupSourcingStrategy()
IfComponent.getMarkupSourcingStrategy()
returns null, this method will be called.-
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, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, onComponentTagBody, onDetach, onInitialize, onRender, 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, onAfterRender, onBeforeRender, 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 org.apache.wicket.IQueueRegion
dequeue, getRegionMarkup
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
Fragment
public Fragment(String id, String markupId, MarkupContainer markupProvider)
Constructor.- Parameters:
id
- The component idmarkupId
- The associated id of the associated markup fragmentmarkupProvider
- The component whose markup contains the fragment's markup- See Also:
Component(String)
-
Fragment
public Fragment(String id, String markupId, MarkupContainer markupProvider, IModel<?> model)
Constructor.- Parameters:
id
- The component idmarkupId
- The associated id of the associated markup fragmentmarkupProvider
- The component whose markup contains the fragment's markupmodel
- The model for this fragment- See Also:
Component(String)
-
-
Method Detail
-
newMarkupSourcingStrategy
protected IMarkupSourcingStrategy newMarkupSourcingStrategy()
IfComponent.getMarkupSourcingStrategy()
returns null, this method will be called. By default it returns null, which means that a default markup strategy will be attached to the component.Please note that markup source strategies are not persisted. Instead they get re-created by calling this method again. That's ok since markup sourcing strategies usually do not maintain a state.
- Overrides:
newMarkupSourcingStrategy
in classComponent
- Returns:
- Markup sourcing strategy
-
chooseMarkup
protected IMarkupFragment chooseMarkup(MarkupContainer provider)
Get the markup stream which shall be used to search for the fragment- Parameters:
provider
-- Returns:
- The markup stream to be used to find the fragment markup
-
getAssociatedMarkupId
public final String getAssociatedMarkupId()
- Returns:
- the markup id associated to this Fragment
-
newDequeueContext
public DequeueContext newDequeueContext()
Description copied from interface:IQueueRegion
Creates a newDequeueContext
that will be used to dequeue children of this region. Usually containers will create a context with their associated markup by getting it viaMarkupContainer.getAssociatedMarkup()
, but components that do not render markup in a standard way (such as repeaters and borders) may choose to override this method to implement custom behavior for the dequeueing process.- Specified by:
newDequeueContext
in interfaceIQueueRegion
- Overrides:
newDequeueContext
in classMarkupContainer
- See Also:
IQueueRegion.newDequeueContext()
-
-