0

我有一个有效的 NullableStringListEditor 实现:

public class NullableStringListEditor extends Composite implements IsEditor<OptionalFieldEditor< List<String>, ListEditor<String, StringEditor> >> {...}

现在,我通过包装它来构建一个 NullableStringSetEditor:

public class NullableStringSetEditor extends Composite implements ValueAwareEditor<Set<String>>, LeafValueEditor<Set<String>> {
private NullableStringListEditor wrappedEditor = new NullableStringListEditor();

    @Override
    public void setValue(Set<String> values) {
        List<String> list = wrappedEditor.asEditor().getValue();
        some null checking... 
        list.clear();
        list.addAll(values);
        wrappedEditor.asEditor().setValue(list); // will call setValue of OptionalFieldEditor from here
    }
}

错误:

java.lang.NullPointerException: null at com.google.gwt.editor.client.adapters.OptionalFieldEditor.setValue(OptionalFieldEditor.java:113)

第 113 行:chain.attach(value, subEditor); 似乎链总是空的。

难道我做错了什么?谢谢!

4

1 回答 1

0

如果NullableStringSetEditor是 a LeafvalueEditor,那么wrappedEditor编辑器框架生成器将忽略它,因此不会被初始化和填充。

您可能希望通过让您的编辑器成为 a (除了成为 a )来遵循该OptionaEditor模式CompositeEditorLeafValueEditor

于 2012-08-30T12:47:05.790 回答