Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleMyResourceReference.java
borderStylesolid
@Override
public List<HeaderItem> getDependencies() {
  List<HeaderItem> dependencies = super.getDependencies();
  dependencies.add(dep1);
  dependencies.add(dep2);
  return dependencies;
}
org.apache.wicket.model.StringResourceModel constructor accepts IModel<String> for its default value WICKET-4972

There were two problems with the old way:

  • since the parameters argument type is Object..., i.e. varargs, it was hard for the compiler and runtime to differentiate the "defaultValue" from the "parameters"
  • it wasn't possible to use lazy evaluation of the default value

If in your application you have code like:

Code Block
titleMyComponent.java
borderStylesolid

StringResourceModel model = new StringResourceModel(resourceKey, model, "Some default value", new Object[] [param1, param2]);

then the simplest solution is to use Model.of("Some default value"):

Code Block
titleMyComponent.java
borderStylesolid

StringResourceModel model = new StringResourceModel(resourceKey, model, Model.of("Some default value"), new Object[] [param1, param2]);