Wicket Remove

wicket.markup.html.basic.Label

[back to the reference]

You use a label to display strings on your page.

A static label just prints out the text you fed it:
static text

Actually, each label has an instance of IModel backing it. This means we can create dynamic labels, like this label that prints out the current date/time.
5/6/24
One of the first things you probably noticed, is that the date is nicely formatted, hopefully even in your locale's format. This is because Wicket works with converters. Converters are fully customizable and allow you to do any mapping of incomming request parameters (from text), and outgoing display values (to text). Usually you won't need to bother with converters yourself. Wicket comes with sensible defaults.

A lot of times, you want to get the actual text from some other location, like a resource bundle:
Did you know your current browser''s locale is en?
In this case, the actual display text will be loaded from resource bundle 'LabelPage.properties', and {0} will be replaced with the locale argument we fed it.

Normally, markup characters will be escaped for you in order to prevent all kinds of troubles/ mess up attempts. However in this example, we actually want any markup to be interpreted by the browser
now that is a pretty bold statement!


Behind the Scenes

Example HTML

<span wicket:id="markupLabel" class="mark">this text will be replaced</span>

Example Code

        Label markupLabel = new Label("markupLabel", "now <i>that</i> is a pretty <b>bold</b> statement!");
        markupLabel.setEscapeModelStrings(false);
        add(markupLabel);

Further examples & and comments/explanations may be available in the source code.