我不知道为什么这不起作用。GWT编辑器框架ListEditor
首先。我的行为是这样,我会忽略代码,试图更好地解释:
public class ProgramaEditor extends Composite implements Editor<ProgramaProxy> {
/*edits a ProgramaProxy just fine*/
/* a EditorList to edit BitacoraProxy */
@UiField BitacoraListEditor bitacoras;
}
public class BitacoraListEditor extends Composite implements IsEditor<ListEditor<BitacoraProxy, BitacoraEditor>>, HasRequestContext<List<BitacoraProxy>>{
/* edit a list of BitacoraProxy just fine */
protected class BitacoraEditorSource extends EditorSource<BitacoraEditor>{
/* the editor source that vends Editors of BitacoraProxy*/
public BitacoraEditor create(int index) {
final BitacoraEditor editor = new BitacoraEditor();
editor.setIndex(index);
/*more code*/
editor.addDeleteEditorHanlder(new EditorDeleteHandler() {
/* ... handler to remove a Editor from the list */
subeditors.getList().remove(event.getIndex());
}
}
}
private ListEditor<BitacoraProxy, BitacoraEditor> subeditors = ListEditor.of(new BitacoraEditorSource());
}
在服务器端:
@Entity
public class Bitacora extends EntityBase {
@NotNull(message="La fecha no puede ser nulo")
private Date fecha;
}
所以一切运作良好的正常工作流程编辑ProgramaProxy再加入BitacoraProxys和然后保存,我可以使用ListEditor保存ProgramaProxy和它的@OneToMany BitacoraProxy。
问题是,当我从EditorList与删除BitacoraProxy:
subeditors.getList().remove(event.getIndex());
/*Please note the @NotNull on the Many side on the property fecha.*/
当我保存整个对象,我得到constrait侵犯财产:
@NotNull(message="La fecha no puede ser nulo")
private Date fecha;
为什么?我只是debugued我的代码和ListEditor其同步我的意思是:
Add a BitacoraProxy -> ListEditor.getList() - size = 1
Then I remove a BitacoraProxy from the ListEditor.getList() - size = 0
没有BitacoraProxy在ListEditor的GetList(),然后保存按钮:
driver.flush().fire(new Receiver<Void>() {
@Override
public void onSuccess(Void response) {
}
@Override
public void onConstraintViolation(Set<ConstraintViolation<?>> violations) {
DialogHandler handler = DialogHandler.getInstance();
ErrorDialog errDlg = handler.createErrorDialog();
for(ConstraintViolation<?> violation:violations){
errDlg.addDetail(violation.getMessage());
}
/* more code */
});
为什么我'歌厅违反约束在ListEditor.getList()中不存在的Proxys。
任何帮助将是apreciated。
谢谢。
喜托马斯TODO,感谢您的回答。在ListEditor(CompositeEditor)上从列表中移除时,可能需要有一些信息告诉RequestContext移除该EntityProxy ?.我刚刚删除了@NotNull,然后在客户端验证我的字段。 – 2012-04-20 16:48:34