2012-04-03 43 views
0

我刚开始使用GWT。我编写了教程here。但是,当我创建新项目并在水平面板中添加了两个按钮,然后在RootPanel中,它向我显示了我在HTML文件中创建的标题。你能告诉我可能是什么原因吗? 这里是Java类中,HTML和XML: 的Java类:新GWT应用程序中的按钮

package org.elsys.salvation.client; 

import com.google.gwt.core.client.EntryPoint; 
import com.google.gwt.user.client.ui.Button; 
import com.google.gwt.user.client.ui.HorizontalPanel; 
import com.google.gwt.user.client.ui.Label; 
import com.google.gwt.user.client.ui.RootPanel; 


public class Salvation implements EntryPoint { 

    private Button newData = new Button("New"); 
    private Button existingData = new Button("Existing"); 
    private HorizontalPanel mainHorizontalPanel = new HorizontalPanel(); 
    private Label lastUpdatedLabel = new Label(); 

    public void onModuleLoad() { 
     mainHorizontalPanel.add(newData); 
     mainHorizontalPanel.add(existingData); 
     mainHorizontalPanel.add(lastUpdatedLabel); 

     RootPanel.get("Salvation").add(mainHorizontalPanel); 
    } 

} 

的HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
    <head> 
     <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
     <link type="text/css" rel="stylesheet" href="Salvation.css"> 
     <title>Diploma Defences Organiser</title> 
     <script type="text/javascript" language="javascript" src="stockwatcher/stockwatcher.nocache.js"></script> 
    </head> 
    <body> 

     <h1>Diploma Defences Organiser</h1> 
     <div id="Salvation"></div> 
     <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> 
     <noscript> 
      <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif"> 
      Your web browser must have JavaScript enabled 
      in order for this application to display correctly. 
      </div> 
     </noscript> 
    </body> 
</html> 

和XML:

<?xml version="1.0" encoding="UTF-8"?> 
<module rename-to='Salvation'> 
    <!-- 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          --> 

    <!-- Specify the app entry point class.       --> 
    <entry-point class='org.elsys.salvation.client.Salvation'/> 

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

</module> 
+0

你是怎么开始这个项目的。你在编码环境中使用eclipse吗? – Stefan 2012-04-03 14:18:41

+0

是的,日食:) – malkoto1 2012-04-03 15:30:42

回答

0

检查该行是否是否正确:

<script type="text/javascript" language="javascript" src="stockwatcher/stockwatcher.nocache.js"></script> 

我认为你应该有这样的:Salvation/Salvation.nocache.js作为脚本标记的来源。

+0

我修正了它,但只是头只显示... – malkoto1 2012-04-03 15:17:53

+0

@ malkoto1检查.nocache.js文件可以从该URL访问,它应该工作,如果nocache.js文件可从该页面。 ... – 2012-04-03 16:07:22

0

在您选择的浏览器中打开开发者控制台。您应该能够跟踪所做的网络请求。确保你的* nocache.js文件被调用并且恢复正常(状态200)。

如果这样工作确定没有其他的明显跳出来对我。也许尝试不指定要加载到的div?

RootLayoutPanel.get().add(mainHorizontalPanel); 
+0

正在调用javascript,但在控制台中出现以下错误:Uncaught TypeError:“无法设置属性'__gwt_getProperty'的未定义”,它在该行代码之后出现: “function B(){if(p && q ){var b = m.getElementById(O); var c = b.contentWindow; if(A()){c .__ gwt_getProperty = function(a){return F(a)}} Salvation = null; c.gwtOnLoad y,O,s,x); n && n({moduleName:O,sessionId:o,subSystem:P,evtGroup:V,millis:(new Date).getTime(),type:W})}}“ – malkoto1 2012-04-03 16:10:47

+0

这就是生成的js很难在视觉上进行调试。你是从eclipse中的tomcat服务器运行还是编译然后部署? – 2012-04-03 17:01:42

+0

我正在使用eclipse的Developement模式并运行它 – malkoto1 2012-04-03 17:41:51