与えられたエディタが作業しているオブジェクトへの参照を取得するには、2通りの方法があります。まず、いくつかの単純なデータや簡易エディタ:まず
public class MyModel {
//sub properties...
}
public class MyModelEditor implements Editor<MyModel> {
// subproperty editors...
}
:代わりにEditor
を実装するので、我々はまた、サブエディタエディタを拡張しますが、ことができます別のインターフェイスを選択することができます(LeafValueEditor
はサブエディタを許可していません)。 ValueAwareEditor
を試すことができます:
public class MyModelEditor2 implements ValueAwareEditor<MyModel> {
// subproperty editors...
// ValueAwareEditor methods:
public void setValue(MyModel value) {
// This will be called automatically with the current value when
// driver.edit is called.
}
public void flush() {
// If you were going to make any changes, do them here, this is called
// when the driver flushes.
}
public void onPropertyChange(String... paths) {
// Probably not needed in your case, but allows for some notification
// when subproperties are changed - mostly used by RequestFactory so far.
}
public void setDelegate(EditorDelegate<MyModel> delegate) {
// grants access to the delegate, so the property change events can
// be requested, among other things. Probably not needed either.
}
}
これは上記の例のように様々な方法を実装する必要がありますが、あなたが興味を持っている主なものは、setValue
になります。これらを自分で呼び出す必要はなく、ドライバとその代理人によって呼び出されます。 flush
メソッドは、オブジェクトを変更する予定がある場合にも使用してください。フラッシュ前にこれらの変更を加えると、予想されるドライバのライフサイクルの外にオブジェクトを変更することになります。 。
第二:SimpleEditor
サブエディタを使用します。
これを使用して
public class MyModelEditor2 implements ValueAwareEditor<MyModel> {
// subproperty editors...
// one extra sub-property:
@Path("")//bound to the MyModel itself
SimpleEditor self = SimpleEditor.of();
//...
}
、あなたは現在の値が何であるかを読み出すためself.getValue()
を呼び出すことができます。
編集:私はあれば今すぐ
:AnotherEditor
あなたは、他のサブエディタをしたいかもしれませんが、あなたは、GWTクラスSimpleEditor
のようなものを作るために始めているように見える、実装しました見てみます同じプロキシのsubeditor
public class AntoherClass implements Editor<Proxy>{
someMethod(){
// method to get the editing proxy ?
}
}
このsubeditorはValueAwareEditor<Proxy>
代わりのEditor<Proxy>
を実装することができ、そしてそのsetValue
メートルことが保証さを得ました編集開始時にProxyインスタンスでethodが呼び出されます。
はい、それは動作しますが、私はちょうどValueAwareEditorを実装し、setValueのは自動的にプロキシを設定する必要があります。 APIから "編集中の値に基づいて動作が変更される編集者は、このインターフェースを実装します。"それは私の場合です。 =) –
このヘルプのためのコリンありがとうございました。(私は@Path( "")のためにespacially:@Path( "this")をやるように誘惑されましたが、特別な扱いが必要でした...) データ値に応じてエディタから別のエディタに切り替える方法を知っている。フォームを変更する必要のある選択ボックスがあります(多くの一般的なフィールドがありますが、レイアウトやいくつかのフィールドがappaer/disappear)。私は各タイプのUiBinderを持っていますが、私はユーザーの選択で1つから別のものに切り替えたいと思います。私はそれらをすべて作り、状況に応じてそれらを見えるようにするという考えが好きではありません。新しいエディタを作成してそれを属性にしたい –