slot bindings for htmlpanel

GWT Designer allows you to quickly create the modules, composites, panels, remote services and other elements that comprise Google Web Tookit applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

slot bindings for htmlpanel

Postby andrewmcveigh » Wed May 02, 2007 5:52 am

is there any current support for binding widgets to slots in htmlpanel?

I have 2 situations:

1. I place a HTMLPanel on the form and add in the html with something like ...<td id="slot1">... I then cannot find a way to bind a widget to slot1 in the designer, although if I do it programmatically it works and shows up in the designer.

2. I create a Composite with an embedded HTMLPanel and expose the panel via a getPanel() call (very nice, BTW). Again, the html is something like ...<td id="slot1">... If I then place the composite on another form, and try to programmatically bind the slot1 to a button, I get a null ptr exception from the designer. It works fine if I just display it in the hosted browser.

For (2) I could probably live with doing it programmatically, but the crash makes life very difficult at the moment.

Cheers,
Andrew
p.s. when it crashes in (2) it asks me if I want to send mail to support. I click yes, and it opens about 20 tabs in firefox, each with part of the description line (which appears to say something like "please give us a description in full with screenshots...")!
andrewmcveigh
 
Posts: 23
Joined: Sat Apr 14, 2007 12:47 pm
Location: London, UK

Re: slot bindings for htmlpanel

Postby Eric Clayberg » Wed May 02, 2007 3:04 pm

andrewmcveigh wrote:1. I place a HTMLPanel on the form and add in the html with something like ...<td id="slot1">... I then cannot find a way to bind a widget to slot1 in the designer, although if I do it programmatically it works and shows up in the designer.

GWT Designer does not yet support doing this in the design view.

andrewmcveigh wrote:2. I create a Composite with an embedded HTMLPanel and expose the panel via a getPanel() call (very nice, BTW). Again, the html is something like ...<td id="slot1">... If I then place the composite on another form, and try to programmatically bind the slot1 to a button, I get a null ptr exception from the designer. It works fine if I just display it in the hosted browser.

Here's an example showing how to do this...

Code: Select all
package com.mycompany.project.client;

import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;

public class MyExposedHTMLComposite extends Composite {
   private HTMLPanel m_htmlPanel;
   private AbsolutePanel absolutePanel;

   public MyExposedHTMLComposite() {
      m_htmlPanel = new HTMLPanel("<table border='1'><tr height='100'><td id='slot1' width='300'></tr></table>");
      initWidget(m_htmlPanel);

      absolutePanel = new AbsolutePanel();
      absolutePanel.setSize("100%", "100%");
      m_htmlPanel.add(absolutePanel, "slot1");
   }
   public AbsolutePanel getSlot1() {
      return absolutePanel;
   }
}

Code: Select all
package com.mycompany.project.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.mycompany.project.client.MyExposedHTMLComposite;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class ImageViewer implements EntryPoint {
   private Button clickMeButton;
   public void onModuleLoad() {
      RootPanel rootPanel = RootPanel.get();

      clickMeButton = new Button();
      rootPanel.add(clickMeButton);
      clickMeButton.setText("Click me!");
      clickMeButton.addClickListener(new ClickListener() {
         public void onClick(Widget sender) {
            Window.alert("Hello, GWT World!");
         }
      });

      final MyExposedHTMLComposite myExposedHTMLComposite = new MyExposedHTMLComposite();
      rootPanel.add(myExposedHTMLComposite, 69, 60);
      myExposedHTMLComposite.setSize("377px", "276px");

      final Button button = new Button();
      myExposedHTMLComposite.getSlot1().add(button);
      button.setText("New Button");
   }
}

Note that you can add additional widgets to "slot1" via drag/drop.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby andrewmcveigh » Thu May 03, 2007 11:51 am

Wow -- works an absolute treat. Even works for recursive application -- i.e. putting a html widget with a slot into the slot of another instance of the html widget and so on. Cool.

Cheers,
Andrew
andrewmcveigh
 
Posts: 23
Joined: Sat Apr 14, 2007 12:47 pm
Location: London, UK


Return to GWT Designer

Who is online

Users browsing this forum: No registered users and 3 guests