开发者

Google GWT RPC Vector

I use Google GWT and RPC. On the Client side is the class SplitDatenhalter. This works OK:

Vector <SplitDatenhalter> vec = new Vector<SplitDatenhalter>();
vec.add(new SplitDatenhalter("a", "b", "c","D"));
vec.add(new SplitDatenhalter("ab", "bc", "dc","Dee"));

How can I send this to the server side?

Update

I have on the client side the class SplitDatenhalter. See below,

public class SplitDatenhalter implements Serializable{

private static final long serialVersionUID = 1L;
String name ;
String vorname;
String nachname;
String email;


public SplitDatenhalter(String name, String vorname, String Nname, String Email) {      
    this.name = name;
    this.vorname = vorname;
    this.nachname = Nname; 
    this.email = Email;
} 

public String getName() {
    return name;
}
//others setter and getter Function

The client side has MyService:

public interface MyService extends RemoteService  
{     
    public void  myVector(Vector<SplitDatenhalter> vec); 
}

The other interface:

public interface MyServiceAsync {
    public void myVector(Vector < SplitDatenhalter > vec,
                 AsyncCallback < Void > callback);
}

This is the server side:

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();
开发者_JAVA百科    }
}

This code part is from client side:

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 

I need this code part

public static MyServiceAsync getService()
{
    MyServiceAsync svc = (MyServiceAsync) GWT.create(MyService.class);
    ServiceDefTarget endpoint = (ServiceDefTarget) svc;
    endpoint.setServiceEntryPoint("/myService");
    return svc;
}

The last part:

@ SuppressWarnings("unchecked")
public void vectorExe()
{
    System.out.println("vectorExe befor");
    getService().myVector(this.vect, callback);
}

After this function executes, I get an error from onFailure(Throwable caught). Where did I go wrong?


you can use vector in client and pass it fto server side (see reference)

Maybe your SplitDatenhalter class is not Serializable. What's the problem?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜