Reputation: 1699
I'm currently having problems with GWT and Eclipse. In my current implementation when i run > debug as > web application i don't get any widgets on my html page, even though i'm loading them to a div on the page.
In the pic you can see my folder organization on this project.
And the code to all the relevant files is the following:
Anacom.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='AnacomGWT'>
<inherits name='com.google.gwt.user.User' />
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<entry-point class='pt.ist.anacom.presentationserver.client.AnacomGWT' />
<source path='client' />
</module>
AnacomGWT.java
package pt.ist.anacom.presentationserver.client;
import com.google.gwt.core.client.EntryPoint;
public class AnacomGWT implements EntryPoint{
private VerticalPanel mainPanel = new VerticalPanel();
private HorizontalPanel inserePanel = new HorizontalPanel();
private TextBox numBox = new TextBox();
private Button numBtn = new Button();
private HorizontalPanel smsPanel = new HorizontalPanel();
private TextArea smsText = new TextArea();
private TextBox smsBox = new TextBox();
private Button smsBtn = new Button();
private HorizontalPanel saldoPanel = new HorizontalPanel();
private TextBox saldoBox = new TextBox();
private Button saldoBtn = new Button();
private HorizontalPanel modoPanel = new HorizontalPanel();
private Label modoId = new Label();
private Button desligadoBtn = new Button();
private Button ligadoBtn = new Button();
private Button silencioBtn = new Button();
private Button ocupadoBtn = new Button();
@Override
public void onModuleLoad() {
// Assemble insereBox
inserePanel.add(numBox);
inserePanel.add(numBtn);
//assemble smsPanel
smsPanel.add(smsText);
smsPanel.add(smsBox);
smsPanel.add(smsBtn);
//assemble saldoPanel
saldoPanel.add(saldoBox);
saldoPanel.add(saldoBtn);
//assemble modoPanel
modoPanel.add(modoId);
modoPanel.add(desligadoBtn);
modoPanel.add(ligadoBtn);
modoPanel.add(silencioBtn);
modoPanel.add(ocupadoBtn);
//assemble mainPanel
mainPanel.add(inserePanel);
mainPanel.add(smsPanel);
mainPanel.add(saldoPanel);
mainPanel.add(modoPanel);
RootPanel.get("contents").add(mainPanel);
numBox.setFocus(true);
}
}
Anacom.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Anacom</title>
</head>
<body>
<h1>Anacom</h1>
<div id="contents"></div>
</body>
</html>
and finally web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<welcome-file-list>
<welcome-file>Anacom.html</welcome-file>
</welcome-file-list>
</web-app>
When i run the application as a web application, in the link i get, i can only see the "ANACOM" that is wrapped in the tag, and none of the panels i defined on anacomGWT.java, which should appear on the "contents" div as i'm calling with:
RootPanel.get("contents").add(mainPanel);
Anybody knows what's wrong with my code?
Upvotes: 1
Views: 991
Reputation: 2940
I didn't find any connection between your html and GWT. you are not specifying which gwt module will be used in your html page(Anacom.html.) . use
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Anacom</title>
<script type="text/javascript" language="javascript" src="anacom/anacom.nocache.js"></script>
</head>
<body>
<h1>Anacom</h1>
<div id="contents"></div>
</body>
</html>
Upvotes: 4
Reputation: 4608
Maybe you have to set the width/height of at least one of the elements/panels?
You should try one of the developer tools on your browser (native on IE/chrome, Firebug on Fx) and see what elements are actually created on the DOM. That will provide some meaningful information on your debugging.
Upvotes: 0