如何编辑一个<?使用GWT Editor框架扩展EntityProxy>?

Bor*_*ich 5 gwt requestfactory gwt-editors

为简单起见:

public class Person 
{
    String name; 
    Set<Address> addresses;
}

public class Address
{
     String city;
     String street;
}
Run Code Online (Sandbox Code Playgroud)

与匹配

public interface PersonProxy extends EntityProxy 
{
     public String getName();
     public Set<AdressProxy> getAddresses();
}
Run Code Online (Sandbox Code Playgroud)

public interface AdressProxy extends EntityProxy 
{
    public String getCity();
    public String getStreet();
}
Run Code Online (Sandbox Code Playgroud)

我得到了UiBuinder类来编辑AddressProxy,如果我有List但是数据是在Person类中设置的,我如何使用ListEditor来清楚我如何使用ListEditor?如何使用Editor Framework来编辑它们?或者可能是当它变成PersonProxy时如何将Set转换为List?

我尝试了一种可以实现的适配器编辑器类

LeafValueEditor<Set<AddressProxy>>
Run Code Online (Sandbox Code Playgroud)

然后在LeafValueEditor.setValue()内部移动到List并在单独的Editor层次结构上启动一个新的driver.edit(),该层次结构负责List编辑但现在运气好了.

Tho*_*yer 6

你应该创建一个CompositeEditor<Set<AddressProxy>, AddressProxy, AddressEditor>,类似于a ListEditor但处理a Set而不是a List.我想你可以以某种方式委托给ListEditor我,但我真的不确定.

  • 问题是a)按定义设置没有特定的顺序,值的子编辑器必然是_list_,b)你可能想在编辑过程中允许重复值,只检查_flush_时的唯一性,但是你必须以某种方式告诉用户何时是这种情况("嘿,我有4个值,当我保存它时只保留了3个!"); 和唯一性取决于你如何在编辑的对象中实现`equals()`.如果你能想出一个_standard_`SetEditor`,那么请你贡献一下! (2认同)