tags:

views:

584

answers:

2

Hi,

I tried sending an ArrayList to an RPC service in GWT but keeps on failing. Here is my code fragment

       greetingService.addNewQuestion(questionnaireKey, questionText, qcList, new AsyncCallback<Boolean>(){
    @Override
    public void onFailure(Throwable caught) {
     Window.alert("Something went wrong!\n"+caught.getMessage());

    }
    @Override
    public void onSuccess(Boolean result) {
     Window.alert("Question Added!");
    }

   });

QuestionChoice is a simple object with no method, and qcList is an ArrayList of QuestionChoice

public class QuestionChoice implements IsSerializable{
/**
 * 
 */
private static final long serialVersionUID = 5668640935838672293L;
public String text;
public boolean isCorrect;

public QuestionChoice(){

}
public QuestionChoice(String text, boolean isCorrect){
 this.text = text;
 this.isCorrect = isCorrect;
}

}

Has anyone tried sending an ArrayList as a parameter in GWT-RPC? If you do, please try to post your sample code here. Thank you.

+1  A: 

If you are using GWT 1.5 and Java 1.6, the problem is the @Override annotation, you are not really overriding a method, you are implementing. Get rid of the annotation and everything should go fine.

Isac
At java 1.6 language level @Override annotation is allowed for implementing interface method also.ivanceras may use java 1.6 language level.
BlackPanther
Ok, but GWT complains about it. When you use @Override on an implemented method it causes an error that shows up on the developer shell. Well, at least it happens with me.
Isac
Actually this problem just happens if you are using GWT 1.5 and Java 1.6. Sorry about that.
Isac
A: 

Yes, It is possible to send an ArrayList as a parameter in GWT-RPC call. When developing the GWT-RPC code, a lot of times you may encounter errors when a request in GWT-RPC is invoked, this is due to a change in GWT-RPC service that may have not been corresponds to the clients compiled GWT-RPC definition. To solve this issue you have to restart your development server whenever you changed your codes in the server side classes, or in the GWT-RPC service defintion(ie GreetingService, GreetingServiceAsync and in GreetingServiceImpl)

ivanceras