| A Label component replaces its body with the String version of its model
object returned by getModelObjectAsString().
Exactly what is displayed as the body, depends on the model. The simplest
case is a Label with a static String model, which can be constructed like
this:
add(new Label("myLabel", "the string to display"))
A Label with a dynamic model can be created like this:
add(new Label("myLabel", new PropertyModel(person, "name"));
In this case, the Label component will replace the body of the tag it is
attached to with the 'name' property of the given Person object, where Person
might look like:
public class Person
{
private String name;
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
}
author: Jonathan Locke |