Monday, July 23, 2012

Re: GWT components/panels on an externally hosted web page

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 <mdichiappari@gmail.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.


--
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-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

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

No comments:

Post a Comment