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 {@link #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 {@link #addToBorder(Component)}.
{@link #add(Component)} is an alias to {@code getBodyContainer().add(Component...)} and willadd 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 {@link #remove()}, {@link #get(int)}, {@link #iterator()}, etc. are not aliased to work on the border's body and attention must be paid when they need to be used.
@see PanelBorder An alternative implementation based on Panel
@see BorderBehavior A behavior which add (raw) markup before and after the component
@author Jonathan Locke
@author Juergen Donnerstag