嗨,我刚开始使用GWT和我得到以下错误,当我在Eclipse中运行项目GWT 2.2 RootPanel CSS错误
19:36:16.084 [错误] [adaptivgwt] 警告: com.google.gwt.user.client.ui.RootPanel 后代将是不正确地定位 ,即不相对于它们 父元素,当 “位置:静态”,这是CSS 默认,在影响。一个可能的 修复程序是调用 'panel.getElement()。getStyle()。setPosition(Position.RELATIVE)'。
java.lang.IllegalStateException: com.google.gwt.user.client.ui.RootPanel 缺少CSS '位置:{相对的,绝对的,固定}' 在com.google.gwt.user。 client.ui.AbsolutePanel.verifyPositionNotStatic(AbsolutePanel.java:279) at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:118) at com.ivstel.adaptiv.client.AdaptivGWT。 loadLogin(AdaptivGWT.java:29) 在com.ivstel.adaptiv.client.AdaptivGWT.onModuleLoad(AdaptivGWT.java:21) 在sun.reflect.NativeMethodAccessorImpl.invoke0(母语 方法) 在sun.reflect.NativeMethodAccessorImpl。调用(UNKN自己 源) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知 来源) 在java.lang.reflect.Method.invoke(未知 来源) 在com.google.gwt.dev.shell.ModuleSpace.onLoad( ModuleSpace.java:396) at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:183) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510) 在com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352) 在java.lang.Thread.run(未知来源)
这是我的entry point样子:
public class AdaptivGWT implements EntryPoint {
private static AdaptivGWT singleton;
public static AdaptivGWT get() {
return singleton;
}
public void onModuleLoad() {
singleton = this;
loadLogin();
}
public void loadLogin() {
RootPanel.get("login").clear();
RootPanel.get("main").clear();
LoginGWT login = new LoginGWT();
RootPanel.get("login").add(login, 10, 10);
}
public void loadMain(User user) {
RootPanel.get("login").clear();
MainGWT main = new MainGWT();
RootPanel.get("main").add(main, 10, 10);
}
}
HTML文件。
<!doctype html>
<!-- The DOCTYPE declaration above will set the -->
<!-- browser's rendering engine into -->
<!-- "Standards Mode". Replacing this declaration -->
<!-- with a "Quirks Mode" doctype may lead to some -->
<!-- differences in layout. -->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="AdaptivGWT.css">
<title>Adaptiv</title>
<script type="text/javascript" language="javascript" src="adaptivgwt/adaptivgwt.nocache.js"></script>
</head>
<body>
<!-- OPTIONAL: include this if you want history support -->
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
<!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
<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>
<div id="login"></div>
<div id="main"></div>
</body>
</html>
我的猜测是这个问题的答案是在这里没有显示的部分:您的主html文件,其中包含'main'和'login'标记的html元素。所以你也可以添加html。 – 2011-02-28 10:41:51
添加了html文件。 – 2011-02-28 12:23:48