开发者

what IsSerializable or not in GWT?

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开发者_如何学Go;
    }

    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:

  1. 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
  2. All non-final, non-transient instance fields are themselves serializable, and
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜