Interop issue: GWT widget doesn't show

Hi there,

I’m running into some interoperability issues while trying to integrate GWT widgets with SmartGWT layouts. One of which is GWT widget not showing after it was removed and then added back to the Layout. I tried the same for SmartGWT widget and it worked perfectly.

Here is the code to illustrate this issue:

  public void onModuleLoad() {
    final VLayout layout = new VLayout();
    layout.setWidth100();
    layout.setHeight100();    
    
    final WidgetCanvas hello = new WidgetCanvas(new com.google.gwt.user.client.ui.Label("Hello"));
    //final Label hello = new Label("Hello");
    final Canvas add = new IButton("Add");
    final Canvas remove = new IButton("Remove");
    
    remove.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        // 1. click on the remove button to remove hello label
        layout.removeMember(hello);
        remove.disable();
        add.enable();
      }
    });
    
    add.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        // 2. add the label back but this time it doesn't show up
        layout.addMember(hello, 0);
        add.disable();
        remove.enable();
      }
    });
    add.disable();
    
    layout.addMember(hello);    
    layout.addMember(remove);
    layout.addMember(add);
    
    layout.draw();
  }

Any help would be much appreciated.

Thanks in advanced.

–Kevin

Has anyone having this issue? Are there any workarounds?

some things off the top of my head i think might / or might not help.

try

layout.markForRedraw() method after readding

or insteading of using add() remove()

try hide() and show()?

matttai,

markForRedraw() doesn’t address the issue.

hide() and show() would address the issue in this example but that’s just a simple example I came up to illustrate this issue. add/remove/add combinations are set of primitive operations that allow us to move widgets around and attach/detach various widgets on the same location without reconstructing those widgets which in some cases are expensive and unnecessary.

In any case,thanks for your help.

Same problem

@knguyen

See http://forums.smartclient.com/showthread.php?p=16757#post16757
and following posts.

@jbat

Thanks for link.

Maybe I’m missing something here but issue in that post is not much related to the one I’m having. I’m not doing anything fancy here: just adding a simple gwt widget (a Label) to a SmartGWT canvas, removing it, then adding it back again which then it’s not visible any more. I wonder if SmartGWT added some state to the WidgetCanvas that prevents it from being rendered to the DOM on the second try.