RequestFactory不会填充我的实体代理的所有字段 [英] RequestFactory doesn't populate all fields of my entity proxy
问题描述
你能告诉我如何让RequestFactory填充实体代理的实体代理的字段吗?
这里是父代理
@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的样子
@ProxyFor(value = Person.class,locator = PojoLocator.class)
public接口PersonProxy扩展了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);
$ b $ p $在我的 RequestContext
接口我有方法请求< OrganizationProxy> findOrganizationById(长ID)
。从数据存储中获取真实组织的DAO类设置它的 contactPerson
字段,但在客户端它总是 null
。实际上,RequestFactory从来都不会调用Organization.getContactPerson()。
我的客户端调用看起来像这样
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);
//将对象中的数据复制到UI
driver.edit (organizationProxy);
}
@Override
public void onFailure(ServerFailure error)
{
createConfirmationDialogBox(error.getMessage())。center( );
}
});
我在这里错过了什么?我应该手动做点什么吗?是不是RequestFactory应该填充整个图?
解决方案很抱歉,我找到了答案。我应该有RTFM。
查询服务器时,RequestFactory不会自动在对象图中填充
关系。为此,请在请求中使用with()
方法,并将相关属性名称指定为String
Could you please tell me how I can make RequestFactory populate fields of my entity proxy that are entity proxies too ?
Here is parent proxy
@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);
}
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);
}
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();
}
});
What am I missing here ? Shall I do something somewhere manually ? Isn't RequestFactory supposed to populate whole graph ?
解决方案 Sorry but I found the answer. I should have RTFM.
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屋!