【发布时间】:2011-02-28 08:44:15
【问题描述】:
大家好,我刚开始使用 GWT,当我在 Eclipse 中运行项目时遇到以下错误
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) 在 com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:118) 在 com.ivstel.adaptiv.client.AdaptivGWT.loadLogin(AdaptivGWT.java:29) 在 com.ivstel.adaptiv.client.AdaptivGWT.onModuleLoad(AdaptivGWT.java:21) 在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native 方法) 在 sun.reflect.NativeMethodAccessorImpl.invoke(未知 资源) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(未知 资源) 在 java.lang.reflect.Method.invoke(未知 资源) 在 com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396) 在 com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:183) 在 com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510) 在 com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352) 在 java.lang.Thread.run(Unknown Source)
这就是我的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吗?
标签: gwt