Wednesday, June 29, 2011

Re: Transient methods and imports

GWT honors the transient keyword. Simply mark any non-GWT-safe fields as transient:

private transient NonGWTSafeType someField;


HTH,
/dmc

On Wed, Jun 29, 2011 at 2:50 AM, Christie Davel <christiedavel@gmail.com> wrote:
Is there anyway how one can mark certain methods/imports as transient
for the gwt compiler.  By doing this i can use the same pojo on client
and server side where the transient methods will be ignored on the
client side.

An Example:


package bla.bla.dto.basemodel;

import com.extjs.gxt.ui.client.data.BaseModelData;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class EntityBase extends BaseModelData {
   public EntityBase() {
   }

   public Long getPk() {
       return get("pk");
   }

   public void setPk(Long pk) {
       set("pk", pk);
   }

   @GWTTransient
   private void writeObject(ObjectOutputStream out) throws
IOException {
       out.defaultWriteObject();
       ...
   }

   @GWTTransient
   private void readObject(ObjectInputStream in) throws IOException,
ClassNotFoundException {
       in.defaultReadObject();
       ...
   }
}

Regards
Christie

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.




--
David Chandler
Developer Programs Engineer, Google Web Toolkit
w: http://code.google.com/
b: http://googlewebtoolkit.blogspot.com/
t: @googledevtools

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment