public abstract class Border extends WebMarkupContainer implements IComponentResolver, IQueueRegion
The portion of the border's associated markup file which is to be used in rendering the border is denoted by a <wicket:border> tag. The children of the border component instance are then inserted into this markup, replacing the first <wicket:body> tag in the border's associated markup.
For example, if a border's associated markup looked like this:
<html> <body> <wicket:border> First <wicket:body/> Last </wicket:border> </body> </html>And the border was used on a page like this:
<html> <body> <span wicket:id = "myBorder"> Middle </span> </body> </html>Then the resulting HTML would look like this:
<html> <body> First Middle Last </body> </html>In other words, the body of the myBorder component is substituted into the border's associated markup at the position indicated by the <wicket:body> tag.
Regarding <wicket:body/> you have two options. Either use <wicket:body/> (open-close tag) which will automatically be expanded to <wicket:body>body content</wicket:body> or use <wicket:body>preview region</wicket:body> in your border's markup. The preview region (everything in between the open and close tag) will automatically be removed.
The border body container will automatically be created for you and added to the border
container. It is accessible via getBodyContainer()
. In case the body markup is not an
immediate child of border (see the example below), then you must use code such as
someContainer.add(getBodyContainer())
to add the body component to the correct
container.
<html> <body> <wicket:border> <span wicket:id="someContainer"> <wicket:body/> </span> </wicket:border> </body> </html>The component "someContainer" in the previous example must be added to the border, and not the body, which is achieved via
addToBorder(Component...)
.
add(Component...)
is an alias to getBodyContainer().add(Component...)
and will
add a child component to the border body as shown in the example below.
<html> <body> <span wicket:id = "myBorder"> <input wicket:id="name"/;> </span> </body> </html>This implementation does not apply any magic with respect to component handling. In doubt think simple. But everything you can do with a MarkupContainer or Component, you can do with a Border or its Body as well. Other methods like
Component.remove()
, MarkupContainer.get(int)
, MarkupContainer.iterator()
, etc. are not
aliased to work on the border's body and attention must be paid when they need to be used.An alternative implementation based on Panel
,
A behavior which adds (raw) markup before and after the component
,
Serialized FormModifier and Type | Class and Description |
---|---|
class |
Border.BorderBodyContainer
The container to be associated with the <wicket:body> tag
|
Modifier and Type | Field and Description |
---|---|
static String |
BODY |
static String |
BORDER |
ENABLE, FLAG_AFTER_RENDERING, FLAG_INITIALIZED, FLAG_PREPARED_FOR_RENDER, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RENDERING, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING
Constructor and Description |
---|
Border(String id) |
Border(String id,
IModel<?> model) |
Modifier and Type | Method and Description |
---|---|
Border |
add(Component... children)
This is for all components which have been added to the markup like this:
|
protected void |
addDequeuedComponent(Component component,
ComponentTag tag)
Adds a dequeued component to this container.
|
Border |
addOrReplace(Component... children)
Replaces a child component of this container with another or just adds it in case no child
with the same id existed yet.
|
Border |
addToBorder(Component... children)
Adds children components to the Border itself
|
protected DequeueTagAction |
canDequeueTag(ComponentTag tag)
Checks if this container can dequeue a child represented by the specified tag.
|
Component |
findComponentToDequeue(ComponentTag tag)
Queries this container to find a child that can be dequeued that matches the specified tag.
|
Border.BorderBodyContainer |
getBodyContainer() |
IMarkupFragment |
getMarkup(Component child)
Search for the child markup in the file associated with the Border.
|
IMarkupFragment |
getRegionMarkup()
Returns the markup inside <wicket:border> tag.
|
protected IMarkupSourcingStrategy |
newMarkupSourcingStrategy()
If
Component.getMarkupSourcingStrategy() returns null, this method will be called. |
protected void |
onInitialize()
This method is meant to be used as an alternative to initialize components.
|
Border |
queueToBorder(Component... children)
Queues children components to the Border itself
|
Border |
remove(Component component)
Removes a component from the children identified by the
component.getId() |
Border |
remove(String id)
Removes the given component
|
Border |
removeAll()
Removes all children from this container.
|
Border |
removeFromBorder(Component child)
Removes child from the Border itself
|
Border |
replace(Component replacement)
Replaces a child component of this container with another
|
Border |
replaceInBorder(Component component)
Replaces component in the Border itself
|
Component |
resolve(MarkupContainer container,
MarkupStream markupStream,
ComponentTag tag)
Try to resolve a component.
|
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
autoAdd, contains, dequeue, dequeue, dequeuePreamble, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkupType, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onAfterRenderChildren, onComponentTagBody, onDetach, onRender, queue, renderAll, renderAssociatedMarkup, renderNext, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildren
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, canCallListenerInterfaceAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, 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, 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, internalPrepareForRender, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onBeforeRender, onComponentTag, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setRequestFlag, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, visitParents, warn, wrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dequeue, newDequeueContext
public static final String BODY
public static final String BORDER
public Border(String id)
Component.Component(String)
public Border(String id, IModel<?> model)
Component.Component(String, IModel)
protected void onInitialize()
Component
Page
thus providing the component with an atomic callback
when the component's environment is built out.
Overrides must call super#Component.onInitialize()
. Usually this should be the first thing an
override does, much like a constructor.
Parent containers are guaranteed to be initialized before their children
It is safe to use Component.getPage()
in this method
NOTE:The timing of this call is not precise, the contract is that it is called sometime
before Component.onBeforeRender()
.
onInitialize
in class MarkupContainer
public final Border.BorderBodyContainer getBodyContainer()
public Border add(Component... children)
<span wicket:id="myBorder"> <input wicket:id="text1" .. /> ... </span>Whereas
addToBorder(Component...)
will add a component associated with the following
markup:
<wicket:border> <form wicket:id="myForm" .. > <wicket:body/> </form> </wicket:border>
add
in class MarkupContainer
children
- The child(ren) to add.MarkupContainer.add(org.apache.wicket.Component[])
public Border addOrReplace(Component... children)
MarkupContainer
addOrReplace
in class MarkupContainer
children
- The child(ren) to be added or replacedpublic Border remove(Component component)
MarkupContainer
component.getId()
remove
in class MarkupContainer
component
- Component to remove from this containerthis
for chainingpublic Border remove(String id)
MarkupContainer
remove
in class MarkupContainer
id
- The id of the component to removethis
for chainingpublic Border removeAll()
MarkupContainer
Note: implementation does not call MarkupContainer.remove(Component)
for each
component.
removeAll
in class MarkupContainer
this
for method chainingpublic Border replace(Component replacement)
MarkupContainer
replace
in class MarkupContainer
replacement
- The childpublic Border addToBorder(Component... children)
children
- the children components to addpublic Border queueToBorder(Component... children)
children
- the children components to queuepublic Border removeFromBorder(Component child)
child
- this
public Border replaceInBorder(Component component)
component
- this
public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag)
resolve
in interface IComponentResolver
container
- The container parsing its markupmarkupStream
- The current markupStreamtag
- The current component tag while parsing the markupnull
if not foundprotected IMarkupSourcingStrategy newMarkupSourcingStrategy()
Component.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.
newMarkupSourcingStrategy
in class Component
public IMarkupFragment getMarkup(Component child)
getMarkup
in class MarkupContainer
child
- The child component. If null, the container's markup will be returned. See Border,
Panel or Enclosure where getMarkup(null) != getMarkup().Component.getMarkup()
protected DequeueTagAction canDequeueTag(ComponentTag tag)
MarkupContainer
ComponentTag
s are supported as well as WicketTag
s that return
a non-null value from ComponentTag.getAutoComponentFactory()
method.canDequeueTag
in class MarkupContainer
public Component findComponentToDequeue(ComponentTag tag)
MarkupContainer
findComponentToDequeue
in class MarkupContainer
protected void addDequeuedComponent(Component component, ComponentTag tag)
MarkupContainer
MarkupContainer#add(Component...))
method should cover most cases. Components that
implement a custom hierarchy, such as borders, may wish to override it to support edge-case
non-standard behavior.addDequeuedComponent
in class MarkupContainer
public IMarkupFragment getRegionMarkup()
getRegionMarkup
in interface IQueueRegion
getRegionMarkup
in class MarkupContainer
IQueueRegion.getRegionMarkup()
Copyright © 2006–2016 Apache Software Foundation. All rights reserved.