なぜこれがうまくいかないのか、私にはわかりません。
初め。私の行動は次のようなものです。よりよく説明するためにコードを省略します。
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 を追加してから保存すると、ProgramaProxy とその @OneToMany BitacoraProxy を ListEditor で保存できます。
問題は、次のように EditorList から BitacoraProxy を削除するときです。
subeditors.getList().remove(event.getIndex());
/*Please note the @NotNull on the Many side on the property fecha.*/
オブジェクト全体を保存すると、プロパティの制約違反が発生します。
@NotNull(message="La fecha no puede ser nulo")
private Date fecha;
なんで?コードをデバッグしたところ、ListEditor が同期しています。
Add a BitacoraProxy -> ListEditor.getList() - size = 1
Then I remove a BitacoraProxy from the ListEditor.getList() - size = 0
ListEditor getList() に BitacoraProxy がなく、次に [保存] ボタンに:
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() に存在しないプロキシの制約違反が発生するのはなぜですか。
どんな助けでも感謝します。
ありがとうございました。