我不知道爲什麼這不起作用。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