Я не могу понять, почему это не работает.GWT Editor Framework 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 и затем Save, я могу сохранить ProgramaProxy и @OneToMany BitacoraProxy с помощью ListEditor.
Проблема заключается в том, когда я удалить BitacoraProxy из EditorList с:
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 */
});
Почему i'am адресности нарушения ограничений Proxys, который не существует в ListEditor.getList().
Любая помощь будет оценена.
спасибо.
Hi Фомы, спасибо за ваш ответ. В ListEditor (CompositeEditor) при удалении из списка может быть что-то, что сообщает RequestContext удалить EntityProxy ?. Я просто удалил @NotNull, а затем подтвердил свое поле на стороне клиента. –