Wednesday, April 23, 2014

Why doesn't GWTP allow Object (created by us) to pass through ActionHandler?

Ok, Here is the scenarios.

I have:

CustomerPresenter.java in myproject.client package.

GetCustomer.java in myproject.client package.

GetCustomerResult.java in myproject.client package.

Customer.java in myproject.shared package.

GetCustomerActionHandler.java in myproject.shared package.

all these files were automatically generated by eClipse except Customer.java which were created by myself.

CustomerPresenter.java: user can enter customer attributes into textbox & click button then the system should search customers that match the attributes provided.

GetCustomer.java to hold customer attributes such as setCustomerName & getCustomerName, setEmail.. etc

GetCustomerResult.java has setCustomer(customer) & getCustomer(); // customer from shared package

GetCustomerActionHandler.java connect to Db & select name, email... then pass these info into Customer. Ex:

In GetCustomerActionHandler.java

@Override  public GetCustomerResult execute(GetCustomer action, ExecutionContext context)              throws ActionException {      String sql="select name, email... from Customer...";      .....      String name=dbResults.getString(1);      Customer c =new Customer();      c.setName(name);      GetCustomerResult getCustomerResult=new GetCustomerResult();      getCustomerResult.setCustomer(c);      return getCustomerResult;    }  

But after ran, i got this err:

Starting Jetty on port 8888     [WARN] Exception while dispatching incoming RPC call  com.google.gwt.user.client.rpc.SerializationException: Type 'myproject.shared.Customer' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = myproject.shared.Customer@31e4aa02      at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:665)      at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:126)  ......  

If we don't put data into object at server level then we have to put it at client level, but it will make the code cumbersome.

Maybe we can make Customer become Serialised or something like that... but i have no idea about that technique.

Why that happened? Do you know how to fix it? 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment