开发者

Sending an ArrayList as a parameter in GWT-RPC

I tried sending an ArrayList to an RPC service in GWT but k开发者_StackOverflow中文版eeps 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.


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)


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜