2012-04-20 4 views
0

なぜこれがうまくいかないのか分かりません。GWT Editor Framework ListEditor

最初。私の行動は次のようなものですが、私はより良い説明しようとするコードを省略します:その後、BitacoraProxysを追加

@Entity 
public class Bitacora extends EntityBase { 
    @NotNull(message="La fecha no puede ser nulo") 
    private Date fecha;  
} 

だから、すべてが通常のワークフロー編集ProgramaProxyにうまく機能して:サーバー側で

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()); 
} 

をSaveをクリックすると、Listaditorで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; 

なぜ? i'amは、制約違反をgetingなぜ

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上

Add a BitacoraProxy -> ListEditor.getList() - size = 1 
Then I remove a BitacoraProxy from the ListEditor.getList() - size = 0 

ノーBitacoraProxy()、[保存]ボタン上:私はちょうど私のコードとListEditorその同期に私が意味をdebugued ListEditor.getList()に存在しないProxysのリストです。

すべてのヘルプはapreciatedされるだろう。

ありがとうございます。

答えて

0

あなたBitacoraProxyは、したがって、それはRequestContextの一部ですので、(少なくともエディタフレームワークによって)edit()編となっている、と(あなたがそのプロパティの一部を変更しない限り、それのIDのみ)サーバーに送信され、意志それが後で使用されるかどうかは検証されません。

これは既知の問題(1)ですが、RequestFactoryのオリジナルデザインの一部であったため、実際にどうすればよいかわからないを修正しました。 issue 5926も参照してください。


(1)http://gwt-code-reviews.appspot.com/1601806/diff/9001/user/src/com/google/web/bindery/requestfactory/shared/impl/AbstractRequestContext.java#newcode1182

+0

こんにちはトーマスでTODOを参照してください、あなたの答えをありがとうございました。 ListEditor(CompositeEditor)では、リストから削除するときに、RequestContextがそのEntityProxyを削除するよう指示する何かが必要なことがあります。私は@NotNullを削除して、クライアント側で自分のフィールドを検証しました。 –