我有一个有效的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); 似乎链总是空的。
我做错了吗?谢谢!
答案 0 :(得分:0)
如果NullableStringSetEditor
是LeafvalueEditor
,那么编辑器框架生成器将忽略wrappedEditor
,因此不会对其进行初始化和填充。
您可能希望关注OptionaEditor
模式,让您的编辑器成为CompositeEditor
(除了成为LeafValueEditor
)