java - GWT RF: How to share the same code in client and server -


i use same code sort , manipulate objects in client , server sides.

but facing problem since in client need proxy interface representing class of server.

is there way use same interface in both?, know rf has mechanism copy bean attributes server instance client instance when sent through wire.

as thomas says in answer, way in current gwt have shared code in client , sever implementing same interface in both sides , using in shared code.

since rf copies attributes server client in query, in theory use same interface (the proxy one) in both sides (simpler code), setting @valuefor value pointing itself.

lets see example:

 // shared interface in client , server sides  @proxyfor(foo.class)  interface foo extends valueproxy {     string getbar();  }   // server side implementation  class fooimpl implements foo {     string getbar(){return "bar";};  } 

as information, use approach in our product, can sell 2 backend solutions (one based on gae , other on couchdb).

the code above works client code not create new values, if want create them, enough define value locator:

 // rf locator use create classes in server side  @proxyfor(value = foo.class, locator alocator.class)  interface foo extends valueproxy {  }   public class alocator extends locator<foo, string>  {    public foo create(class<? extends foo> clazz) {     return new fooimpl();    }    ...  } 

unfortunately, rf not deal interfaces in server side see issues: 7509 , 5762.

but, can read in issues comments, there fix (pending review). included in next release of gwt.

in meanwhile, can use approach, copying file resolverservicelayer.java in src folder , applying patch it.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -