GWT:在简单的Hello应用程序中获取错误

时间:2012-01-20 21:02:37

标签: gwt intellij-idea

我在IntelliJ中运行一个基本的GWT应用程序,下面是我的代码

           public class test implements EntryPoint {

/**
 * This is the entry point method.
 */
public void onModuleLoad() {
    final Button button = new Button("Click me");
    final Label label = new Label();

    button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (label.getText().equals("")) {


                 testService.App.getInstance().getMessage("h", new AsyncCallback<Inter>() {
                     public void onFailure(Throwable caught) {
                         //To change body of implemented methods use File | Settings | File Templates.
                     }

                     public void onSuccess(Inter result) {
                        label.setText(result.getToken());
                     }
                 });
            } else {
                label.setText("");
            }
        }
    });

Impl Class

        public class testServiceImpl extends RemoteServiceServlet implements testService {
// Implementation of sample interface method
public Inter getMessage(String msg) {
    RdbHelper rdbHelper = new RdbHelper();
    return rdbHelper.getMsg();

}

}

RdbHelper Class

    public class RdbHelper {

public Inter getMsg(){
    Inter inter = new Inter();
    return inter;
}

}

国际班级

        public class Inter implements Serializable{

private String token ;

public String getToken() {
    token = "Hello";
    return token;
}

public void setToken(String token) {
    this.token = token;
}

}

我应该看到msg“Hello”,但是我收到了这个错误。

       ERROR: Errors in 'file:/C:/work/Grails/TestFinal/src/com/test/client/test.java'. 
       ERROR: Unable to find type 'com.test.client.test'. 
       ERROR: Line 28: No source code is available for type com.test.shared.Inter; did  you forget to inherit a required module?. 
     ERROR: Hint: Previous compiler errors may have made this type unavailable. 
     ERROR: Hint: Check the inheritance chain from your module; it may not be   inheriting a required module or a module may not be adding its source path entries   properly. 
     ERROR: Failed to load module 'test' from user agent 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7' at 127.0.0.1:51070. 

注意:我在Eclipse中尝试相同的事情并且工作正常,但这是我在IntelliJ中遇到的问题

1 个答案:

答案 0 :(得分:2)

你记得放

吗?
<source path="shared"/>
在您的Module.gwt.xml文件中

。 您需要这样做才能将共享包中的代码编译为javascript代码。如果不是,它只编译客户端软件包中的代码,从而客户端无法使用共享文件夹中的代码。