Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added the capabilities of property expression syntax

...

  • "property1.property2": Both properties are looked up in the same way as mentioned above. If the property1 evaluates to null and there exists a setter with name property1 on the model object and the class representing the class representing property1 has a default constructor then a new instance will be constructed and assigned on the model object via the property1 and the property2 will be set on this new object.

...

Wiki Markup
Index or map properties can be alternatively written as: {{"property\[index\]"}} or {{"property\[key\]"}}.

For example, if we have a following class:

Code Block
titlePerson.java
borderStylesolid

public static class Person {
  private String name;

  private Person parent;

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Person getParent() {
    return parent;
  }

  public void setParent(Person parent) {
    this.parent = parent;
  }
}

Then we can use the following expressions:

  • name can be used to access getters and setter for the name property
  • parent.name can be used to retrieve or set the name of a parent. If there is no parent set (i. e. it is null), a new instance of Person is created and set on the model object. Thereafter a name property is get/set on this new instance.
Panel
titleFrom the mailing list

We started out with OGNL in the past but:
1) OGNL at one point took about 30% processor time of the whole request. We simplified and optimized and wrote OGNL out.
2) We feel it's not the recommended way of programming to rely on property expressions beyond simple navigations
3) By overriding wicket.model.AbstractPropertyModel#onGetObject(wicket.Component) and AbstractPropertyModel#onSetObject(Component, Object) users can provide their own resolving if necessary.

Eelco Hillenius