I'd go with Approach 1, or possibly approach 3:
in start-activity:
* driver = view.createEditorDriver (which returns a RequestFactoryEditorDriver)
* OrderDescriptionProxy proxy = context.create(OrderDescriptionProxy.class)
* context.placeOrder(proxy).to(new Receiver<String>() {
@Override
public void onSuccess(String response) {
GWT.log("Got response: " + response);
}
});
* driver.edit(proxy, context)
* view.setDelegate(this)
in on-submit (called from view on presenter):
@Appraoch1: because I'm curious
when I using approach1 and I do the following in on-submit:
* driver.flush.fire();
on the server i receive the following request:
{"O":[{"T":"gwtapp.client.ui.invoice.order.rf.OrderDescriptionProxy","P":{"customerId":"cid","vehicleLicensePlate":"plate","productCode":"pcode"},"C":2,"R":"1","O":"PERSIST"}]}
and this response is returned:
{"O":[{"T":"gwtapp.client.ui.invoice.order.rf.OrderDescriptionProxy","R":"1","C":2}]}
Remeber I call driver.flush().fire() which will transmit a ValueProxy not anentityProxy. What is happening here - will there an new instance of OrderDescription be created on the server side??
A new instance will be created, its setCustomerId, setVehicleLicensePlate and setProductCode will be called, then nothing will be done because you didn't queue any invocation.
Actually I was expecting an exception?
I think you'd have one with an EntityProxy because it wouldn't have been persisted (you wouldn't have an exception if the EntityProxy weren't created on the client using RequestContext.create, but previously retrieved from the server).
But with ValueProxies, there's really no reason to throw an exception: you send a proxy with a bunch of operations and no invocation, why would it throw? (because there's no invocation? well, on the other hand, running the code you asked to be run just works without throwing, so...)
(I mean, it's not illogical, it's just a choice of implementation IMO)