RequestFactory不会填充我的实体代理的所有字段 [英] RequestFactory doesn't populate all fields of my entity proxy
问题描述
能否请您告诉我如何使RequestFactory填充实体代理的实体代理字段?
Could you please tell me how I can make RequestFactory populate fields of my entity proxy that are entity proxies too ?
这是父级代理
@ProxyFor(value = Organization.class, locator = PojoLocator.class)
public interface OrganizationProxy extends EntityProxy
{
public String getName();
public void setName(String name);
public String getAddress();
public void setAddress(String address);
public PersonProxy getContactPerson();
public void setContactPerson(PersonProxy contactPerson);
}
如您所见,它包含另一个代理作为字段.这是PersonProxy的样子
as you can see it contains another proxy as field. Here is how PersonProxy looks like
@ProxyFor(value = Person.class, locator = PojoLocator.class)
public interface PersonProxy extends EntityProxy
{
public String getName();
public void setName(String name);
public String getPhoneNumber();
public void setPhoneNumber(String phoneNumber);
public String getEmail();
public void setEmail(String email);
public OrganizationProxy getOrganization();
public void setOrganization(OrganizationProxy organization);
}
在我的 RequestContext
接口中,我有方法 Request< OrganizationProxy> ;;findOrganizationById(长ID)
.从数据存储中获取真实组织的DAO类将设置其 contactPerson
字段,但在客户端中,该字段始终为 null
.实际上,RequestFactory甚至都不会调用Organization.getContactPerson().
In my RequestContext
interface I have method Request<OrganizationProxy> findOrganizationById(long id)
. DAO class that fetches real Organization from datastore sets its contactPerson
field but in the client it's always null
. In fact RequestFactory never even calls Organization.getContactPerson().
我的客户呼叫看起来像这样
My client call looks like this
createFactory().contextOrder().findOrganizationById(1).fire(new Receiver<OrganizationProxy>()
{
@Override
public void onSuccess(OrganizationProxy response)
{
if (response == null)
{
organizationProxy = orderRequestContext.create(OrganizationProxy.class);
organizationProxy.setContactPerson(orderRequestContext.create(PersonProxy.class));
} else
organizationProxy = orderRequestContext.edit(response);
// Copy the data in the object into the UI
driver.edit(organizationProxy);
}
@Override
public void onFailure(ServerFailure error)
{
createConfirmationDialogBox(error.getMessage()).center();
}
});
我在这里想念什么?我可以在某个地方手动做些事情吗?RequestFactory不应该填充整个图形吗?
What am I missing here ? Shall I do something somewhere manually ? Isn't RequestFactory supposed to populate whole graph ?
推荐答案
对不起,但我找到了答案.我应该有RTFM.
Sorry but I found the answer. I should have RTFM.
查询服务器时,RequestFactory不会自动在对象图中填充关系.为此,请使用with()请求的方法,并指定相关属性名称为String
When querying the server, RequestFactory does not automatically populate relations in the object graph. To do this, use the with() method on a request and specify the related property name as a String
这篇关于RequestFactory不会填充我的实体代理的所有字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!