Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: there is no second constructor on PropertyModel as of Wicket 1.3; Model#getObject(Component) is deprecated too

...

Info
titleMore information on the syntax

More information on the allowed property expressions can be found either in the wicket.util.lang.PropertyResolver JavaDoc or on the Property Expression Language wiki page

A second constructor on PropertyModel is available for models that wish to access properties involving type conversions:

Code Block

public PropertyModel(final Object modelObject, final String expression, Class propertyType)

Although the property expression parser will do automatic type conversions for you, it may not always do the kind of conversion you desire. This alternative constructor creates a property model that forces a particular conversion to occur. For example, you may wish to access a String or Object property of something as an Integer. Constructing a PropertyModel with new PropertyModel(object, "myString", Integer.class) would force the property to be converted to and from an Integer on get/set operations.

Compound property models

If you have looked at some examples of Wicket already, you may have wondered why components, which generally must have a model, can be constructed with only an id, omitting any model. There are three reasons for this.

...

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));

...