2011-02-09 14 views

答えて

7

GWT 2.1.1では、IdプロパティとVersionプロパティはRequestFactoryがどのように転送するのかを知っているどんなタイプのものでもよい。基本的に、プリミティブ型(int)、ボックス型(Integer)、または関連するプロキシ型を持つオブジェクト。コンポジットidを自分でStringに減らす必要はありません。 RF配管は、エンティティ型キーの永続IDまたは値型キーのシリアライズされた状態を使用して、コンポジットキーを自動的に処理できます。あなたがドメイン型の単一getId()プロパティに身元を減らすことができない場合は、外部で定義されたIDとバージョンを提供するために、Locatorを使用することができます

interface Location { 
    public String getDepartment(); 
    public String getDesk(); 
} 

interface Employee { 
    public Location getId(); 
    public int getVersion(); 
} 

@ProxyFor(Location.class) 
interface LocationProxy extends ValueProxy { 
    // ValueProxy means no requirement for getId()/getVersion() 
    String getDepartment(); 
    String getDesk(); 
} 
@ProxyFor(Employee.class) 
interface EmployeeProxy extends EntityProxy { 
    // Use a composite type as an id key 
    LocationProxy getId(); 
    // Version could also be a complex type 
    int getVersion(); 
} 

:以前に掲載の例を使用して

プロパティ。たとえば、次の質問からリンク

@ProxyFor(value = Employee.class, locator = EmployeeLocator.class) 
interface EmployeeProxy {.....} 

class EmployeeLocator extends Locator<Employee, String> { 
    // There are several other methods to implement, too 
    String getId(Employee domainObject) { return domainObject.getDepartment() + " " + domainObject.getDesk(); } 
} 

AppBuilderはDevguideは、複合ID *が*でValueProxy(LocationProxyとしてマップされなければならないことmentionnedされるべきである RequestFactory changes in 2.1.1

+1

に対するビット古くなって上記のサンプルコードでは、EmployeeProxyのgetIdから到達可能です)。これは、GWT.create()d RequestFactoryから始まるインターフェイスとメソッドを歩いているときに到達可能です。 –

+0

ああ、BTWでは、バージョンをプロキシで公開する必要はありません。 –

関連する問題