DTO with interface in client and its implementation in server

69 views
Skip to first unread message

toristone

unread,
Jan 30, 2009, 8:39:51 AM1/30/09
to Google Web Toolkit
Hi all,
I'm currently new to GWT using version 1.5.3 on a linux box. I have a
question that may be asked before, but so far I haven't found a
satisfied answer.
My application consists of three main layer, a kernel (handling most
of the data stuff with several data sources), the web server
middleware, and the client. One of these clients is a GWT-based
client. The web server middleware takes the data from the kernel,
transforms them to data transfer objects (DTO), and sends them to the
client. Since there are several client applications I'd like to use
interfaces instead of implementation classes for data transfer objects
within the GWT client. While using the DTO classes (instead of
interfaces) the application can be initialized, when I use interfaces
I always get the error that the object "... was not serializable and
has no concrete serializable subtypes". May it depends on the
separation of interfaces used in client and implementation classes
used by the server middleware (and available there.

Can anybody help or explain why it doesn't work.
Thanks, Tori


Here is simplified example using the following structure.

MyApp/src/client/MySampleData <-- interface of a
DTO
MyApp/src/client/MySampleService
MyApp/src/client/MySampleServiceAsync
MyApp/src/client/TestView
MyApp/src/client/TestController
MyApp/src/client/MyAppEntryPoint
MyApp/src/public/ ... < standard css and pics as generated by
applicationCreator >
MyApp/src/server/MySampleDataImpl <-- implementation of
the DTO interface
MyApp/src/server/MyServiceServlet

Here are some code snippets for DTO interface and implementation:

// DTO interface
package client;
import java.io.Serializable;

// replacing the interface Serializable with IsSerializable also
brings no success
public interface MySampleData extends Serializable {

public String getName();

}

// DTO implementation
package server;
import java.io.Serializable;
import client.MySampleData;

// replacing the interface Serializable with IsSerializable also
brings no success
public class MySampleDataImpl implements MySampleData, Serializable {

private String name;

public MySampleDataImpl() {
this.name="";
}

public void setName(String name) {
this.name=name;
}

public String getName() {
return this.name;
}

}

Isaac Truett

unread,
Jan 30, 2009, 11:30:48 AM1/30/09
to Google-We...@googlegroups.com
Your DTO implementation is in the server package. However, it needs to
be compiled into JS to work on the client. You can move the impl to
the client package or move the impl and interface to a neutral package
location ("common" or "model" are popular choices, I believe) and
adjust your module definition appropriately.

- Isaac
Reply all
Reply to author
Forward
0 new messages