0

我正在尝试使用 gwt 编辑器框架,以便我可以让我的视图 ( SingleReplayView) 编辑我的 bean SingleClaimId

这是我的视图类:

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());
    }
}

和我的豆类

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
}

当我尝试编译代码时出现错误

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'

可以帮忙吗?

4

1 回答 1

0

gwt.material.design.addins.client.combobox.MaterialComboBox 类型可分配给原始编辑器类型,但需要类型参数化。

错误是在谈论这个(和其他类似的领域):

    @UiField
    MaterialComboBox originalEnvironment;

但是该字段的泛型MaterialComboBox<T>表明它必须在T它正在编辑的类型上是泛型的。https://gwtmaterialdesign.github.io/gwt-material-demo/apidocs-addins/gwt/material/design/addins/client/combobox/MaterialComboBox.html

在这种情况下,您希望 T 与您的 bean 类型中的相同:

    private String originalEnvironment;

所以你@UiField应该阅读

    @UiField
    MaterialComboBox<String> originalEnvironment;

replayEnvironment编辑器也需要相同的参数化。

于 2019-01-24T13:25:29.943 回答