Arrays Google GWT RPC向量
我使用谷歌GWT和RPC。客户端是类Arrays Google GWT RPC向量,arrays,vector,client-server,gwt-rpc,Arrays,Vector,Client Server,Gwt Rpc,我使用谷歌GWT和RPC。客户端是类SplitDatenhalter。这很好用: Vector <SplitDatenhalter> vec = new Vector<SplitDatenhalter>(); vec.add(new SplitDatenhalter("a", "b", "c","D")); vec.add(new SplitDatenhalter("ab", "bc", "dc","Dee")); 客户端有MyService: public inter
SplitDatenhalter
。这很好用:
Vector <SplitDatenhalter> vec = new Vector<SplitDatenhalter>();
vec.add(new SplitDatenhalter("a", "b", "c","D"));
vec.add(new SplitDatenhalter("ab", "bc", "dc","Dee"));
客户端有MyService
:
public interface MyService extends RemoteService
{
public void myVector(Vector<SplitDatenhalter> vec);
}
最后一部分:
@ SuppressWarnings("unchecked")
public void vectorExe()
{
System.out.println("vectorExe befor");
getService().myVector(this.vect, callback);
}
执行此函数后,我从
onFailure(Throwable-catch)
中得到一个错误。我哪里出错了?您可以在客户端使用vector并将其传递到服务器端()
可能您的SplitDatenAlter类不可序列化。有什么问题吗
public interface MyServiceAsync {
public void myVector(Vector < SplitDatenhalter > vec,
AsyncCallback < Void > callback);
}
public void myVector(Vector < SplitDatenhalter > vec)
{
// TODO Auto-generated method stub
System.out.println("vector");
for (int i = 0; i < vec.size(); i++) {
this.name = vec.get(i).getName();
this.name = vec.get(i).getVorname();
this.name = vec.get(i).getNachname();
this.name = vec.get(i).getEmail();
}
}
Vector<SplitDatenhalter> vect = new Vector<SplitDatenhalter>(); // TODO Auto-generated method stub
MyServiceAsync svc = (MyServiceAsync) GWT.create(MyService.class);
ServiceDefTarget endpoint = (ServiceDefTarget) svc;
// endpoint.setServiceEntryPoint("/myService");
// define a handler for what to do when the service returns a result
@SuppressWarnings("rawtypes")
AsyncCallback callback = new AsyncCallback()
{
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
System.out.println("Fehler");
}
//@Override
public void onSuccess(Object result) {
// TODO Auto-generated method stub
System.out.println(result.toString());
}
};
this.vect.add(new SplitDatenhalter(this.name, Vname, Nname, Email)); //this a part from Function
public static MyServiceAsync getService()
{
MyServiceAsync svc = (MyServiceAsync) GWT.create(MyService.class);
ServiceDefTarget endpoint = (ServiceDefTarget) svc;
endpoint.setServiceEntryPoint("/myService");
return svc;
}
@ SuppressWarnings("unchecked")
public void vectorExe()
{
System.out.println("vectorExe befor");
getService().myVector(this.vect, callback);
}