DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
| Code Block |
|---|
public class HelloWorld extends WicketExamplePage
{
public HelloWorld()
{
add(new Label("message", "Hello World!"));
}
}
|
The first parameter to the Label component added in the constructor is the Wicket id, which associates the Label with a tag in the HelloWorld.html markup file:
...
| Code Block |
|---|
import java.util.Date;
public class Person
{
private String name;
private Date birthday;
public Person()
{
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Date getBirthday()
{
return birthday;
}
public void setBirthday(Date birthday)
{
this.birthday = birthday;
}
}
|
Static models
Like we have seen above, the simplest way of providing e.g. a Label a model, is just to provide a string, and let the Label implicitly construct one for you.
...
these statements are adding FormComponents to the Form. But they are not explicitly attached to any model. Instead, they will inherit the CompoundPropertyModel for the form at runtime. When the framework needs the model for a RequiredTextField, it will call getModelObjectAsString().
This method retrieves the text field's model by calling {{getModel()}, which is implemented like this:
...
The model's object value is available in this way to the component for processing. In the case of the stringProperty text field component, it will convert the value to a String. In the case of other {{RequiredTextField}}'s in the FormInput form, a conversion may occur based on the third parameter to the Component. For example, this component:
...
| Code Block |
|---|
final Person person = new Person();
person.setName("Fritzl");
Model model = new Model()
{
public Object getObject(wicket.Component component)
{
return person.getName();
}
};
add(new Label("name", model));
|
...