GWT components/panels on an externally hosted web page

49 views
Skip to first unread message

Mike Dee

unread,
Jul 22, 2012, 9:04:16 PM7/22/12
to google-we...@googlegroups.com
I've created a panel (AbsolutePanel) with a few widgets on it.  They interact with one another (and with a backed via RPC).  

When I include the panel in a web page, nothing appears.  Here's the code.

// MyPanel.java
public class MyPanel extends Composite
{
public  MyPanel  ()
{
AbsolutePanel absolutePanel = new AbsolutePanel();
initWidget(absolutePanel);
Label helloLabel = new Label("Hello");
absolutePanel.add( helloLabel  , 10, 10);
Label byeLabel = new Label("Goodbye");
absolutePanel.add(  byeLabel  , 30, 10);
}
}

// MyApp.java
public class MyApp implements EntryPoint
{
/**
* This is the entry point method.
*/
public void onModuleLoad()
{
RootPanel.get( "myappdiv" ).add( new MyPanel() );
}
}

// index.html
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="myapp/myapp.nocache.js"></script>
</head>
<body">
<div id="myappdiv"/>
</body>
</html>

If I include just one widget (no AbsolutePanel) the widget appears.

public class MyPanel extends Composite
{
public  MyPanel  ()
{
Label helloLabel = new Label("Hello");
initWidget( helloLabel  );
}
}

Are panels (for some reason) not allowed in cases like this?  AbsolutePanel is (derived) from Widget, so it seems like it should work.


Alexandre Ardhuin

unread,
Jul 23, 2012, 3:40:58 AM7/23/12
to google-we...@googlegroups.com
AbsolutePanel has no height by default and "hidden" as value of "overflow" attribute. To make its content appear you have to set its height.

    public void onModuleLoad() {
        MyPanel widget = new MyPanel();
        widget.setHeight("50px");
        RootPanel.get( "myappdiv").add(widget);
    }

Alexandre


2012/7/23 Mike Dee <mdichi...@gmail.com>


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/4sZcoLWYsHwJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Mike Dee

unread,
Jul 23, 2012, 10:58:20 AM7/23/12
to google-we...@googlegroups.com
Brilliant!  That did it.

Thank you.

Reply all
Reply to author
Forward
0 new messages