I have this simple object in my GWT project. I cannot send it over the wire. Is it impossible to put a constructor in such a class?
public class MceDto implements IsSerializable {
public MceDto(String uri, String tag) {
this.uri = uri;
this.tag = tag;
}
public String uri;
public String tag;
public Date created;
}
I checked the *.gwt.rpc policy and the object is not there meaning it is not serializable or something. How can I know beforehand if it is possible to serialize the object?
Thank you
What version of GWT are you using?
The IsSerializable
interface is a vestige of GWT pre-1.4. Have you tried using the Java-standard java.io.Serializable
marker interface?
See this GWT FAQ for more.
As per the GWT serialization docs:
A user-defined class is serializable if all of the following apply:
- It is assignable to
IsSerializable
or Serializable
, either because it directly implements one of these interfaces or because it derives from a superclass that does
- All non-
final
, non-transient
instance fields are themselves serializable, and
- As of GWT 1.5, it must have a default (zero argument) constructor (with any access modifier) or no constructor at all.
So you must provide a no-arg constructor for your class to be serializable by GWT.