我知道這是一個老問題,但這裏是我的兩分錢無論如何。
我在類似場景中遇到了一些麻煩。問題在於可接受的值(AuthorProxy
實例)在RequestContext
中檢索,與BookEditor
用於編輯BookProxy
的值不同。
結果是,當我試圖編輯BookProxy
對象時,當前AuthorProxy
總是在ValueListBox
中重複出現。經過一番研究,我的GWT谷歌組,其中托馬斯解釋說,
中發現this post「EntityProxy#equals()方法實際上比較它們的請求上下文和stableId()。」
因此,我無法改變我的編輯工作流程,我選擇了改變ValueListBox
通過設置自定義ProvidesKey
,在它的比較過程中使用不同的對象場處理其值的方式。
我的最終解決方案是與此類似:
@UiFactory
@Ignore
ValueListBox<AuthorProxy> createValueListBox()
{
return new ValueListBox<AuthorProxy>(new Renderer<AuthorProxy>()
{
...
}, new ProvidesKey<AuthorProxy>()
{
@Override
public Object getKey (AuthorProxy author)
{
return (author != null && author.getId() != null) ? author.getId() : Long.MIN_VALUE;
}
});
}
該解決方案似乎沒給我。我希望它能幫助別人。
感謝您的幫助。另外,你的Posterous上的文檔很棒。這是一個堅實的資源。 http://tbroyer.posterous.com/ –
'ValueListBox'的工作原理是允許我用Author值填充'
你確定你從服務器獲取作者關係嗎? (即在您的RequestFactory請求中包含'.with(「author」)';使用Firebug或類似的方式檢查作者是否從服務器返回)通常,您將使用'.with(editorDriver。getPaths())'以確保您請求所有必需的對象('getPaths'計算來自編輯器/子編輯器的所需關係)。 –