0

我正在使用 GWT 2.5。我有一个使用 gwt-rpc 的应用程序。我已经编译了项目并使用 ant 脚本制作了 war 文件。当我将项目部署在 tomcat 上时,它会成功加载但不显示任何控件。只是一个简单的空白 html 页面。这是我的文件。模块

<?xml version="1.0" encoding="UTF-8"?>
<!--
  When updating your version of GWT, you should also update this DTD reference,
  so that your app can take advantage of the latest GWT module capabilities.
-->
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.0//EN"
  "http://google-web-toolkit.googlecode.com/svn/tags/2.5.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='interviewscheduler'>
  <!-- Inherit the core Web Toolkit stuff.                        -->
  <inherits name='com.google.gwt.user.User'/>

  <!-- Inherit the default GWT style sheet.  You can change       -->
  <!-- the theme of your GWT application by uncommenting          -->
  <!-- any one of the following lines.                            -->
  <inherits name='com.google.gwt.user.theme.clean.Clean'/>
  <!-- <inherits name='com.google.gwt.user.theme.standard.Standard'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
  <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->

  <!-- Other module inherits                                      -->
  <inherits name="com.smartgwt.SmartGwt"/>
  <!-- Specify the app entry point class.                         -->
  <entry-point class='interviewscheduler.client.InterViewScheduler'/>

  <!-- Specify the paths for translatable code                    -->
  <source path='client'/>
  <source path='shared'/>

</module>

远程服务

package interviewscheduler.client;

import interviewscheduler.shared.Interview;
import interviewscheduler.shared.Teacher;

import java.util.LinkedHashMap;
import java.util.List;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("interviewScheduler")
public interface InterviewSchedulerService extends RemoteService{
    Boolean loadStudentData() throws IllegalArgumentException;
    Boolean loadParentData() throws IllegalArgumentException;
    Boolean loadTeacherData() throws IllegalArgumentException;
    Boolean loadClassData() throws IllegalArgumentException;
    Boolean loadClassMemberShipData() throws IllegalArgumentException;
    Boolean loadRoomData() throws IllegalArgumentException;
    Boolean loadSessionData() throws IllegalArgumentException;
    Boolean loadInterviewData() throws IllegalArgumentException;
    LinkedHashMap<String, String> getStudentNames() throws IllegalArgumentException;
    String getParentName(String studentKey) throws IllegalArgumentException;
    List<Teacher> getAvailableTeachers(String studentKey) throws IllegalArgumentException;
    List<Teacher> getRequestedTeachers(String studentKey) throws IllegalArgumentException;
    List<Interview> getInterviewByStudent(String studentKey) throws IllegalArgumentException;
    List<Interview> getInterviewByTeacher(String teacherCode) throws IllegalArgumentException;
    List<Object> getInterviewsForGrid(List<Interview> list) throws IllegalArgumentException;
    String addInterview(Interview obj) throws IllegalArgumentException;
    String removeInterview(String studentId, String teacherId) throws IllegalArgumentException;
}

Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
              http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5"
         xmlns="http://java.sun.com/xml/ns/javaee">

  <!-- Servlets -->

  <servlet>
    <servlet-name>interviewSchedulerServlet</servlet-name>
    <servlet-class>interviewscheduler.server.InterviewSchedulerServiceImpl</servlet-class>
  </servlet>

   <servlet-mapping>
    <servlet-name>interviewSchedulerServlet</servlet-name>
    <url-pattern>/interviewscheduler/interviewScheduler</url-pattern>
  </servlet-mapping>
  <!-- Default page to serve -->

  <welcome-file-list>
    <welcome-file>InterViewScheduler.html</welcome-file>
  </welcome-file-list>

</web-app>

任何想法我做错了什么。这很紧急。

package interviewscheduler.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.smartgwt.client.widgets.layout.VLayout;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class InterViewScheduler implements EntryPoint {
    /**
     * This is the entry point method.
     */
    private InterviewSchedulerServiceAsync remoteObject=GWT.create(InterviewSchedulerService.class);
    private VLayout wrapper=new VLayout();
    private VLayout headerArea=new Header();
    private VLayout contentArea=new ContentArea();

    public void onModuleLoad() {
        Window.enableScrolling(true);
        Window.setMargin("0px");
        remoteObject.loadStudentData(new AsyncCallback<Boolean>() {
            @Override
            public void onSuccess(Boolean result) {

            RootLayoutPanel.get().add(drawWrapper());
            }
            @Override
            public void onFailure(Throwable caught) {
                System.out.println("Failed*****************");
            }
        });


    }

    /** 
     * initialize the wrapper of the web site which holds all other content------Main Container 
     */

    public VLayout drawWrapper(){
        wrapper.setWidth100();
        wrapper.setHeight100();
        wrapper.setMargin(0);
        wrapper.addMember(drawHeaderArea());
        wrapper.addMember(drawContentArea());
        return wrapper;
    }
    /** 
     * initialize the Header Area of the web site which contains Logo with Title and a logout button
     */
    public VLayout drawHeaderArea(){
        headerArea.redraw();
        return headerArea;
    }

    /** 
     * initialize the Content Area of the web site which holds a main TabSet
     */

    public VLayout drawContentArea(){
        contentArea.redraw();
        return contentArea;
    }

}
4

2 回答 2

0

您必须在应用程序中以某种方式显示您的数据。你现在所做的只是调用一堆服务。这实际上很令人困惑。您应该在一次调用服务器时完成所有这些操作。它将为您节省很多往返行程,并且很可能会使您免于遇到一些失败的呼叫。

于 2013-02-12T18:16:35.243 回答
0

愚蠢的错误......我没有在 WEB-INF/lib 目录中包含必要的库。这导致我的 RPC 调用失败。无论如何。特别感谢 Enrybo。调试技术非常有用。

于 2013-02-14T11:02:20.923 回答