You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Michael Gerhards (JIRA)" <ji...@apache.org> on 2018/07/20 12:27:00 UTC
[jira] [Created] (WICKET-6569) LambdaModel.of overload is ambiguous
Michael Gerhards created WICKET-6569:
----------------------------------------
Summary: LambdaModel.of overload is ambiguous
Key: WICKET-6569
URL: https://issues.apache.org/jira/browse/WICKET-6569
Project: Wicket
Issue Type: Wish
Components: wicket
Affects Versions: 8.0.0
Reporter: Michael Gerhards
a method call of
LambdaModel.of(this::getModelObject, this::setModelObject)
refers to
public static <X, R> IModel<R> of(IModel<X> target, SerializableFunction<X, R> getter)
but should be
public static <R> IModel<R> of(SerializableSupplier<R> getter, SerializableConsumer<R> setter)
The problem is that IModel and SerializableSupplier have functionally the same interface:
T getObject(); vs. T get();
Background:
The child component should share its default model object with its parent component's default model object. So if setDefaultModelObject is called on the parent component than the child component should also refer to the new value (and with versa).
Workaround:
public Parent(String wicektId, IModel<Role> roleModel) {
IModel<Role> childRoleModel = new IModel<Role>() {
@Override
public Role getObject() {
return Parent.this.getModelObject();
}
@Override
public void setObject(Role object) {
Parent.this.setModelObject(object);
}
};
add(new Child("child", childRoleModel));
}
Solution:
The problem only exists because .of Method is overloaded. If both methods would have different names (or be in different classes) than the compiler would be fine.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)