I am trying to get a new RequestFactory API and have a very hard time.
My domain models consist of Staffer, a Personand Office. Headquarters has a person and an office as fields.
When I try to save updates to a Staffer instance in GWT, on the server persist()I see updates in my primitive / string fields, but I don't see updates to attachments Personor Officeobjects. Here's how I influence the changes on the GWT side:
private void persistStafferDetails()
{
CRMRequestFactory.StafferRequest stafferRequest = requestFactory.stafferRequest();
staffer = stafferRequest.edit(staffer);
PersonProxy person = staffer.getPerson();
person.setFirstName(firstNameField.getText());
person.setLastName(lastNameField.getText());
staffer.setPersonalEmail(personalEmailField.getText());
staffer.getHomeLocation().setStreetAddress(addressField1.getText());
staffer.getHomeLocation().setCity(cityField.getText());
staffer.getHomeLocation().setPostalCode(postalField.getText());
staffer.getHomeLocation().setProvince(provinceDropDown.getValue(provinceDropDown.getSelectedIndex()));
stafferRequest.persist().using(staffer).fire();
}
Here is the proxy:
@ProxyFor(Staffer.class)
public interface StafferProxy extends EntityProxy
{
Long getId();
PersonProxy getPerson();
void setPerson(PersonProxy person);
OfficeProxy getOffice();
void setOffice(OfficeProxy office);
String getHomePhone();
void setHomePhone(String homePhone);
String getCellPhone();
void setCellPhone(String cellPhone);
String getPersonalEmail();
void setPersonalEmail(String personalEmail);
LocationProxy getHomeLocation();
void setHomeLocation(LocationProxy homeLocation);
}
@ProxyFor(Person.class)
public interface PersonProxy extends EntityProxy
{
Long getId();
void setId(Long id);
String getFirstName();
void setFirstName(String firstName);
String getLastName();
void setLastName(String lastName);
}
@ProxyFor(Office.class)
public interface OfficeProxy extends EntityProxy
{
Long getId();
String getName();
void setName(String name);
}
And my CRMRequestFactory looks like this:
public interface CRMRequestFactory extends RequestFactory
{
@Service(Staffer.class)
public interface StafferRequest extends RequestContext
{
InstanceRequest<StafferProxy, Void> persist();
Request<List<StafferProxy>> getAll();
Request<StafferProxy> findStaffer(Long id);
}
public StafferRequest stafferRequest();
@Service(Person.class)
public interface PersonRequest extends RequestContext
{
InstanceRequest<PersonProxy, Void> persist();
Request<List<PersonProxy>> getAll();
Request<PersonProxy> findPerson(Long id);
}
public PersonRequest personRequest();
@Service(Office.class)
public interface OfficeRequest extends RequestContext
{
InstanceRequest<OfficeProxy, Void> persist();
Request<List<OfficeProxy>> getAll();
Request<OfficeProxy> findOffice(Long id);
}
public OfficeRequest officeRequest();
}
source
share