org.apache.wicket.markup.html.border
Class Border

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.html.border.Border
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<Component>, IEventSink, IEventSource, IClusterable, IConverterLocator, IHeaderContributor, IComponentResolver, IRequestableComponent, IHierarchical<Component>
Direct Known Subclasses:
AjaxFallbackOrderByBorder, BoxBorder, FormComponentFeedbackBorder, NavomaticBorder, OrderByBorder, TemplateBorder

public abstract class Border
extends WebMarkupContainer
implements IComponentResolver

A border component has associated markup which is drawn and determines placement of markup and/or components nested within the border component.

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.

Author:
Jonathan Locke, Juergen Donnerstag
See Also:
An alternative implementation based on Panel, A behavior which add (raw) markup before and after the component, Serialized Form

Nested Class Summary
 class Border.BorderBodyContainer
          The container to be associated with the <wicket:body> tag
 
Field Summary
static java.lang.String BODY
           
static java.lang.String BORDER
           
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER
 
Constructor Summary
Border(java.lang.String id)
           
Border(java.lang.String id, IModel<?> model)
           
 
Method Summary
 Border add(Component... children)
          This is for all components which have been added to the markup like this:
 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
 Border.BorderBodyContainer getBodyContainer()
           
 IMarkupFragment getMarkup(Component child)
          Search for the child markup in the file associated with the Border.
protected  IMarkupSourcingStrategy newMarkupSourcingStrategy()
          If Component.getMarkupSourcingStrategy() returns null, this method will be called.
 Border remove(Component component)
           
 Border remove(java.lang.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.
 
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebPage, getWebRequest
 
Methods inherited from class org.apache.wicket.MarkupContainer
autoAdd, contains, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkupType, hasAssociatedMarkup, internalAdd, internalInitialize, iterator, iterator, onAfterRenderChildren, onComponentTagBody, onMarkupAttached, onRender, renderAll, renderAssociatedMarkup, renderNext, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildren
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, 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, getFeedbackMessage, 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, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, locateMarkupStream, markRendering, modelChanged, modelChanging, onAfterRender, onBeforeRender, onComponentTag, onConfigure, onDetach, onEvent, onInitialize, onModelChanged, onModelChanging, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, 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, warn, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BODY

public static final java.lang.String BODY
See Also:
Constant Field Values

BORDER

public static final java.lang.String BORDER
See Also:
Constant Field Values
Constructor Detail

Border

public Border(java.lang.String id)
See Also:
Component.Component(String)

Border

public Border(java.lang.String id,
              IModel<?> model)
See Also:
Component.Component(String, IModel)
Method Detail

getBodyContainer

public final Border.BorderBodyContainer getBodyContainer()
Returns:
The border body container

add

public Border add(Component... children)
This is for all components which have been added to the markup like this:
        <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>
 
 

Overrides:
add in class MarkupContainer
Parameters:
children - The child(s)
Returns:
This
See Also:
MarkupContainer.add(org.apache.wicket.Component[])

addOrReplace

public Border addOrReplace(Component... children)
Description copied from class: MarkupContainer
Replaces a child component of this container with another or just adds it in case no child with the same id existed yet.

Overrides:
addOrReplace in class MarkupContainer
Parameters:
children - The child(s) to be added or replaced
Returns:
This

remove

public Border remove(Component component)
Overrides:
remove in class MarkupContainer
Parameters:
component - Component to remove from this container
Returns:
this for chaining

remove

public Border remove(java.lang.String id)
Description copied from class: MarkupContainer
Removes the given component

Overrides:
remove in class MarkupContainer
Parameters:
id - The id of the component to remove
Returns:
this for chaining

removeAll

public Border removeAll()
Description copied from class: MarkupContainer
Removes all children from this container.

Note: implementation does not call MarkupContainer.remove(Component) for each component.

Overrides:
removeAll in class MarkupContainer
Returns:
this for method chaining

replace

public Border replace(Component replacement)
Description copied from class: MarkupContainer
Replaces a child component of this container with another

Overrides:
replace in class MarkupContainer
Parameters:
replacement - The child
Returns:
This

addToBorder

public Border addToBorder(Component... children)
Adds children components to the Border itself

Parameters:
children - the children components to add
Returns:
this

removeFromBorder

public Border removeFromBorder(Component child)
Removes child from the Border itself

Parameters:
child -
Returns:
this

replaceInBorder

public Border replaceInBorder(Component component)
Replaces component in the Border itself

Parameters:
component -
Returns:
this

resolve

public Component resolve(MarkupContainer container,
                         MarkupStream markupStream,
                         ComponentTag tag)
Try to resolve a component.

Specified by:
resolve in interface IComponentResolver
Parameters:
container - The container parsing its markup
markupStream - The current markupStream
tag - The current component tag while parsing the markup
Returns:
component or null if not found

newMarkupSourcingStrategy

protected IMarkupSourcingStrategy newMarkupSourcingStrategy()
If 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.

Overrides:
newMarkupSourcingStrategy in class Component
Returns:
Markup sourcing strategy

getMarkup

public IMarkupFragment getMarkup(Component child)
Search for the child markup in the file associated with the Border. The child markup must in between the <wicket:border> tags.

Overrides:
getMarkup in class MarkupContainer
Parameters:
child - The child component. If null, the container's markup will be returned. See Border, Panel or Enclosure where getMarkup(null) != getMarkup().
Returns:
The childs markup
See Also:
Component.getMarkup()


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.