Search code examples
javagwtrequestfactory

GWT RequestFactory - creating new objects


Let's say you have a server-side entity called MyEntity and you also have all the related stuff on your client side (MyEntityProxy and MyEntityRequest).

Consider the case when you'd like to create a new instance of MyEntity, but you're not really sure if you're going to persist it (like user clicks "Create new MyEntity" and then after editor appears, user clicks "Cancel").

So, you make a call like requestContext.create(MyEntityProxy.class) and you get a new object of type MyEntityProxy. Since it's neither persisted yet nor it has version - what behavior should I expect when working with this object? Is it a common practice at all or should I only work with persisted objects - probably, by making all of them have a flag like boolean reallyExists or boolean temporary?


Solution

  • You can work with new proxy and with proxy that represents entity persisted on server side. So there is really no need to reallyExists flag unless you have specific use-case that requires it.