Every error and behavior i wrote before was inside a Grails+gwt
framework... so i thought that maybe the error i get was something
about the grails/spring fremwork that was trying to do something
so i set up a pure gwt module and test the scott solution
now i get a new kind of error
this the classes i use
/* CLASS fdlservizi.prova.client.dominio.DTO*/
import java.util.Date;
import com.google.gwt.user.client.rpc.IsSerializable;
public class DTO implements IsSerializable {
private Date exposeDateType;
private Long exposeLongType;
private String exposeStringType;
private final transient Object value;
public DTO(Date value) {
this.value = value;
}
public DTO(Long value) {
this.value = value;
}
public DTO(String value) {
this.value = value;
}
/**
* For serialization.
*/
public DTO(Object value) {
this.value = value;
}
public Object getValue() {
return value;
}
}
/* CLASS fdlservizi.prova.client.dominio.DTO_CustomFieldSerializer*/
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.SerializationException;
import com.google.gwt.user.client.rpc.SerializationStreamReader;
import com.google.gwt.user.client.rpc.SerializationStreamWriter;
public class DTO_CustomFieldSerializer {
public static void deserialize(SerializationStreamReader
streamReader, DTO instance) throws SerializationException {
Log.debug("deserialize partito");
// Handled in instantiate.
}
public static DTO instantiate(SerializationStreamReader
streamReader)
throws SerializationException {
Log.debug("instantiate partito");
return new DTO(streamReader.readObject());
}
public static void serialize(SerializationStreamWriter
streamWriter, DTO instance) throws SerializationException {
Log.debug("serialize partito; instance = " + instance);
streamWriter.writeObject(instance.getValue());
}
}
/* CLASS DTO_CustomFieldSerializer.DatiChiamata*/
/* That's the object i want to try to include inside the dto object,
is a pojo dto*/
import com.google.gwt.user.client.rpc.IsSerializable;
import java.util.Date;
public class DatiChiamata implements IsSerializable {
public String id;
public String apertaDa;
[...]
public String descrImpianto;
public String nome;
public String cognome;
[...]
}
/* CLASS fdlservizi.prova.client.RPCService */
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
public class RPCService implements RPCInterfaceAsync
{
RPCInterfaceAsync service = (RPCInterfaceAsync)
GWT.create(RPCInterface.class);
ServiceDefTarget endpoint = (ServiceDefTarget) service;
public RPCService()
{
com.google.gwt.core.client.GWT.log("url: " +
GWT.getModuleBaseURL(),null);
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "rpc");
}
public void testRPC(String message, AsyncCallback callback)
{
service.testRPC(message, callback);
}
public void testDTO(AsyncCallback callback){
service.testDTO(callback);
}
}
/* CLASS RPCService .RPCInterfaceAsync */
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface RPCInterfaceAsync {
void testRPC(String message, AsyncCallback callback);
void testDTO(AsyncCallback callback);
}
/* CLASS fdlservizi.prova.client.RPCService */
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
public class RPCService implements RPCInterfaceAsync
{
RPCInterfaceAsync service = (RPCInterfaceAsync)
GWT.create(RPCInterface.class);
ServiceDefTarget endpoint = (ServiceDefTarget) service;
public RPCService()
{
com.google.gwt.core.client.GWT.log("url: " +
GWT.getModuleBaseURL(),null);
endpoint.setServiceEntryPoint(GWT.getModuleBaseURL() + "rpc");
}
public void testRPC(String message, AsyncCallback callback)
{
service.testRPC(message, callback);
}
public void testDTO(AsyncCallback callback){
service.testDTO(callback);
}
}
/* and that's is the entrypoint*/
/* the rpc inside the second button is working good*/
/* that's is the output i get on the console*/
/* ============= gwt-log-1.5.6 =============Tue Aug 26 15:33:48 CEST
2008=============
[DEBUG] bottone 3 cliccato
26-ago-2008 15.33.49 com.allen_sauer.gwt.log.server.ServerLogImplJDK14
debug
FINE: [DEBUG] bottone 3 cliccato
26-ago-2008 15.33.49 com.allen_sauer.gwt.log.server.ServerLogImplJDK14
debug
FINE: testDTO partito (LOG)
26-ago-2008 15.33.49 com.allen_sauer.gwt.log.server.ServerLogImplJDK14
info
INFO: ============= gwt-log-1.5.6 =============Tue Aug 26 15:33:48
CEST 2008=============
26-ago-2008 15.33.49 com.allen_sauer.gwt.log.server.ServerLogImplJDK14
debug
FINE: datichiamata settato
26-ago-2008 15.33.49 com.allen_sauer.gwt.log.server.ServerLogImplJDK14
debug
FINE: dto settato
26-ago-2008 15.33.49 com.allen_sauer.gwt.log.server.ServerLogImplJDK14
debug
FINE: serialize partito; instance =
fdlservizi.prova.client.dominio.DTO@2f996f
*/
/* CLASS fdlservizi.prova.client.ProvaDTO */
import fdlservizi.prova.client.RPCService;
import fdlservizi.prova.client.dominio.DTO;
import fdlservizi.prova.client.dominio.DatiChiamata;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.allen_sauer.gwt.log.client.Log;
public class ProvaDTO implements EntryPoint {
VerticalPanel verticalPanel = new VerticalPanel();
public void onModuleLoad() {
final Button button = new Button("Click me");
final Label label = new Label();
button.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
if (label.getText().equals(""))
label.setText("Hello World!");
else
label.setText("");
}
});
Button button2 = new Button("Test RPC", new ClickListener() {
public void onClick(Widget sender){
Log.debug("bottone 2 cliccato");
RPCService rpc = new RPCService();
rpc.testRPC("Hello", callback);
}
});
Button button3 = new Button("Test DTO", new ClickListener(){
public void onClick(Widget sender){
Log.debug("bottone 3 cliccato");
RPCService rpc = new RPCService();
rpc.testDTO(callback);
}
});
verticalPanel.add(button);
verticalPanel.add(label);
verticalPanel.add(button2);
verticalPanel.add(button3);
RootPanel.get().add(verticalPanel);
}
AsyncCallback callback = new AsyncCallback()
{
public void onFailure(Throwable caught){
verticalPanel.add(new HTML("Failed: " + caught.getMessage()));
}
public void onSuccess(Object result){
Log.debug("onsuccess partito");
DTO dto = (DTO) result;
String stringa = (String) result;
DatiChiamata datiChiamata = (DatiChiamata)dto.getValue();
verticalPanel.add(new HTML(datiChiamata.nome));
}
};
}