RequestFactory create proxy object serverside

103 views
Skip to first unread message

Jakob Mar

unread,
Jul 25, 2011, 11:05:24 AM7/25/11
to google-we...@googlegroups.com
Using RequestFacory I am trying to create an object on the server like this:

public imterface FooRequestContext extends RequestContext
{
    Request<FooProxy> createByBarId(String barId);//create new Foo object (dose not persist it)
    Request<FooProxy> calculate(FooProxy foo);


createByBarId works fine but when I call calculate I get: Server Error: The requested entity is not available on the server.

I think I understand the reason for this error. But is there any way to tell RequestFactory that this object has not been persisted jet and force it to send the whole object, not just the diff? Just as if it had been created using requestContext.create(FooProxy.class) .

Ryan McFall

unread,
Jul 25, 2011, 6:10:38 PM7/25/11
to Google Web Toolkit
I don't think this will work, nor do I think it should. As far as I
understand it, when you send a proxy reference via a Request, the RF
framework attempts to find the server-side entity the proxy is
referencing (using the ID), and then calls the associated method in
your service implementation passing the server-side entity to the
requested method. Since your object does not exist on the server if
looked up by ID, the call should fail.

If you want this to work, you need to actually persist the object in
createByBarId.

Why do you want to do this? I've wanted to do it in order to get
default values set on the client-side proxy, but not have the object
persisted. Unfortunately that's not possible.

Ryan

Jakob Mar

unread,
Jul 26, 2011, 5:34:25 AM7/26/11
to google-we...@googlegroups.com
Thanks for your reply Ryan.

In my case Foo is just a top of a complicated object graph and yes I want to set the default values, I also want to be able to do calculation on Foo with out persisting it. I guess I could implement it on the client side but that is a lot of work and I am not sure it will pay off.

Any way, returning null in Locator.getId() if the object is't persisted seems to do the trick.

Jakob
Reply all
Reply to author
Forward
0 new messages