public static void replaceOrAppend(Element e, Widget widget) {
    assert e != null && widget != null;
    if ($(e).widget() != null && $(e).widget().isAttached()) {
      replaceWidget($(e).widget(), widget, true);
    } else {
      detachWidget(widget);
      replaceOrAppend(e, widget.getElement());
      attachWidget(widget, getFirstParentWidget(widget));
    }
  }
public static void replaceOrAppend ( Element e , Widget widget ) { assert e != null && widget != null ; if ( $ ( e ) . widget ( ) != null && $ ( e ) . widget ( ) . isAttached ( ) ) { replaceWidget ( $ ( e ) . widget ( ) , widget , true ) ; } else { detachWidget ( widget ) ; replaceOrAppend ( e , widget . getElement ( ) ) ; attachWidget ( widget , getFirstParentWidget ( widget ) ) ; } }
Replace a dom element by a widget.
Old element classes will be copied to the new widget.