1

我正在使用 RequestFactory 从服务器检索对象列表。现在我想排除可以包含长文本的对象的“描述”(字符串)属性。

有没有办法在运行时的 RequestFactory 中做到这一点?

这就是我检索列表的方式

    collectcontextProvider.get().getListObject().fire(
    new Receiver<List<ObjectProxy>>() {
    @Override
    public void onSuccess (List<ObjectProxy> objectList) {
        //display the list
        }           

        @Override
        public void onFailure(ServerFailure error) {
            //Error
          }
        });

我使用休眠

4

1 回答 1

0

假设您希望在应用程序的其他位置使用 description 字段,您将需要一个不暴露该属性的精简代理,当然还有一个返回此类代理列表的服务方法。

@ProxyFor(value=MyObject.class, locator=MyLocator.class)
interface MyObjectLiteProxy extends EntityProxy {
   // all properties but 'description'
}

@ProxyFor(value=MyObject.class, locator=MyLocator.class)
interface MyObjectProxy extend MyObjectLiteProxy {
   String getDescription();
}

@Service(MyService.class)
interface CollectContext extends RequestContext {
   Request<List<MyObjectLiteProxy>> getListObjectLite();

   Request<List<MyObjectProxy>> getListObject();
}

实际上,您甚至可以走得更远,在MyService2 秒内使用相同的实现RequestContext

@Service(MyService.class)
interface CollectLiteContext extends RequestContext {
   Request<List<MyObjectLiteProxy>> getListObject();
}

@Service(MyService.class)
interface CollectContext extends RequestContext {
   Request<List<MyObjectProxy>> getListObject();
}
于 2012-08-27T15:28:52.170 回答