简体   繁体   English

GWT编辑器-MaterialComboBox可分配给原始编辑器类型,但需要类型化参数

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

I'm trying to use the gwt editor framework so that I can have my view ( SingleReplayView ) editing my bean SingleClaimId . 我正在尝试使用gwt编辑器框架,以便可以让我的视图( SingleReplayView )编辑我的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? 可以帮忙吗?

The type gwt.material.design.addins.client.combobox.MaterialComboBox is assignable to the raw Editor type, but a type parameterization is required. gwt.material.design.addins.client.combobox.MaterialComboBox类型可分配给原始Editor类型,但需要对类型进行参数化。

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. 但是,字段MaterialComboBox<T>的泛型表明它必须在正在编辑的T类型上是泛型的。 https://gwtmaterialdesign.github.io/gwt-material-demo/apidocs-addins/gwt/material/design/addins/client/combobox/MaterialComboBox.html 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: 在这种情况下,您希望T与您的bean类型中的T相同:

    private String originalEnvironment;

So your @UiField should read 所以你的@UiField应该读

    @UiField
    MaterialComboBox<String> originalEnvironment;

The replayEnvironment editor will also need the same parameterization. replayEnvironment编辑器也将需要相同的参数设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM