GWT Editors - MaterialComboBox is assignable to the raw Editor type, but a type parameterization is required

112 Views Asked by At

I'm trying to use the gwt editor framework so that I can have my view (SingleReplayView) editing my bean SingleClaimId.

Here is my view class:

public class SingleReplayView extends ViewWithUiHandlers<SingleReplayUiHandlers> implements SingleReplayPresenter.MyView, Editor<ReplayClaimId>  
{
    interface Binder extends UiBinder<Widget, SingleReplayView> {
    }

    public interface SingleReplayDriver extends SimpleBeanEditorDriver<ReplayClaimId, SingleReplayView> {}
    protected static SingleReplayDriver driver = GWT.create(SingleReplayDriver.class);

    @UiField
    MaterialTextBox claimId;

    @UiField
    MaterialComboBox originalEnvironment;

    @UiField
    @Path("replayEnvironment")
    MaterialComboBox replayEnvironment;

    @UiField
    @Path("bmsDisabled")
    MaterialRadioButton bmsDisabled;

    @UiField
    @Path("bmsEnabledWithInjection")
    MaterialRadioButton bmsEnabledWithInjection;

    @UiField
    @Path("bmsEnabledWithNoInjection")
    MaterialRadioButton bmsEnabledWithNoInjection;

    @UiField
    @Path("tariffEnabled")
    MaterialCheckBox tariffEnabled;

    @UiField
    @Path("humDisabled")
    MaterialCheckBox humDisable;

    @Inject
    SingleReplayView(Binder uiBinder) {
        initWidget(uiBinder.createAndBindUi(this));
        driver.initialize(this);
    }

    @UiHandler("singleSubmitButton")
    public void submit(ClickEvent event) {
        ReplayClaimId replayClaimId = driver.flush();
        MaterialToast.fireToast(replayClaimId.getClaimId());
    }
}

and my bean class

public class ReplayClaimId implements IsSerializable {

    private String claimId;
    private String originalEnvironment;
    private String replayEnvironment;

    private Boolean bmsDisabled;
    private Boolean bmsEnabledWithInjection;
    private Boolean bmsEnabledWithNoInjection;

    private Boolean tariffEnabled;
    private Boolean humDisabled;

    //with setters and getters
}

And when I try to compile the code i get error

The type gwt.material.design.addins.client.combobox.MaterialComboBox is assignable to the raw Editor type, but a type parameterization is required.
[INFO]    [ERROR] Errors in 'SingleReplayView.java'

can please assist?

1

There are 1 best solutions below

3
On

The type gwt.material.design.addins.client.combobox.MaterialComboBox is assignable to the raw Editor type, but a type parameterization is required.

The error is talking about this (and other similar fields):

    @UiField
    MaterialComboBox originalEnvironment;

But the generics of the field MaterialComboBox<T> show that it must be generic on the type T which it is editing. https://gwtmaterialdesign.github.io/gwt-material-demo/apidocs-addins/gwt/material/design/addins/client/combobox/MaterialComboBox.html

In this case, you want T to be the same as it is in your bean type:

    private String originalEnvironment;

So your @UiField should read

    @UiField
    MaterialComboBox<String> originalEnvironment;

The replayEnvironment editor will also need the same parameterization.