Wicket Examples - component reference

# 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:
this text will be replaced

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.
this text will be replaced
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:
this text will be replaced
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
this text will be replaced

panel contents come here