Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6569

LambdaModel.of overload is ambiguous

    XMLWordPrintableJSON

    Details

    • Type: Wish
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 8.0.0
    • Fix Version/s: 8.3.0, 9.0.0-M1
    • Component/s: wicket
    • Labels:
      None

      Description

      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.

       

      Please see attached files

        Attachments

        1. myproject.zip
          7 kB
          Michael Gerhards

          Activity

            People

            • Assignee:
              svenmeier Sven Meier
              Reporter:
              michaelgerhards Michael Gerhards
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 4h
                4h
                Remaining:
                Remaining Estimate - 4h
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified