Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何编辑集合<;?扩展EntityProxy>;使用GWT编辑器框架?_Gwt_Requestfactory_Gwt Editors - Fatal编程技术网

如何编辑集合<;?扩展EntityProxy>;使用GWT编辑器框架?

如何编辑集合<;?扩展EntityProxy>;使用GWT编辑器框架?,gwt,requestfactory,gwt-editors,Gwt,Requestfactory,Gwt Editors,为了简单起见: public class Person { String name; Set<Address> addresses; } public class Address { String city; String street; } 我有UiBuinder类来编辑AddressProxy 如果我得到了列表,但数据是在Person类中设置的,那么我很清楚如何使用ListEditor 如何使用编辑器框架编辑它们? 或者,当设置成为Pe

为了简单起见:

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

public class Address
{
     String city;
     String street;
}
我有UiBuinder类来编辑AddressProxy 如果我得到了列表,但数据是在Person类中设置的,那么我很清楚如何使用ListEditor 如何使用编辑器框架编辑它们? 或者,当设置成为PersonProxy时,我如何将其转换为List

我尝试放置一种适配器编辑器类,该类将实现

LeafValueEditor<Set<AddressProxy>>
LeafValueEditor

然后在LeafValueEditor.setValue()的内部移动到一个列表,并在一个单独的编辑器层次结构上启动一个新的驱动程序.edit(),该层次结构负责列表编辑,但现在很幸运

您应该创建一个
复合编辑器
,类似于
列表编辑器
,但处理的是
集合
,而不是
列表

我想你可以通过某种方式委托给一个
列表编辑器,尽管我真的不确定。

我已经用点和路线(一条路线包含N个点):

路线(综合):

点编辑器:

public class PointsEditor implements HasRequestContext<List<PointProxy>>, ValueAwareEditor<List<PointProxy>> {

    List<PointProxy> points = new ArrayList<PointProxy>(); 

    public void add(String id) {
       PointProxy point = ctx.create(PointProxy.class);
       point.setId(id);
       points.add(point);           
    }

谢谢这是一个开始。坦率地说,我希望有一个指向某些代码的链接:-)。我认为GWT应该提供某种类型的标准
SetEditor
(可能委托给
ListEditor
)。我遇到了与OP相同的问题,最终在域类上公开了
List
类型的访问器(转换real
Set
-typed属性),以便能够使用
ListEditor
。但这并不总是可能做到(有时我们只需要在客户端设置明智的行为)。问题是a)按定义设置的集合没有特定的顺序,值的子编辑器必须是一个列表,b)您可能希望在编辑过程中允许重复值,并且只在刷新时检查唯一性,但你必须以某种方式告诉用户什么时候会出现这种情况(“嘿,我有4个值,保存时只保存了3个值!”);唯一性取决于如何在编辑的对象中实现
equals()
。如果你能想出一个标准的
SetEditor
,那么请贡献它!我明白你的意思,但问题是:鉴于PointProxy有几个字段和一个编辑器,我如何连接这些点?请注意,这个问题是关于集合而不是列表编辑的,在GWT SDK中给定了helper类和相应的示例代码,但忘记了提到RouteProxy(EntityProxy)和PointProxy(ValueProxy)。答案上都加了这两个词。试着用集合代替列表。
LeafValueEditor<Set<AddressProxy>>
@UiField
TextBox name;

@Ignore
@UiField
FlexTable listPoints;

PointsEditor pointsEditor = new PointsEditor();

     ....

pointsEditor.add(String id);
public class PointsEditor implements HasRequestContext<List<PointProxy>>, ValueAwareEditor<List<PointProxy>> {

    List<PointProxy> points = new ArrayList<PointProxy>(); 

    public void add(String id) {
       PointProxy point = ctx.create(PointProxy.class);
       point.setId(id);
       points.add(point);           
    }
@Embedded
private List<Point> points = new ArrayList<Point>();
public interface RouteProxy extends EntityProxy {

       abstract List<PointProxy> getPoints();

       abstract void setPoints(List<PointProxy> points);
public interface PointProxy extends ValueProxy {

...

}