Search code examples
javagwtgxt

GXT/GWT widget for the 'object' tag


Is there a widget that is synonymous with the '<object>' tag or can I just use a HTML tag with object:

I was thinking of this but it is not idiomatic:

import com.google.gwt.user.client.ui.HTML;
final HTML h = new HTML("<object width='100%' height='100%' data='/media/invoice1.pdf'></object>");
        container.setCenterWidget(h);


<object width='100%' height='100%' data='/media/invoice1.pdf'></object>

This is with gxt 3.0.1


Solution

  • There isn't any gwt widget wrapping the object tag, but you have the ObjectElement which you can use to create the element and attach it to the document:

      // Create an element and programatically set its attributes
      ObjectElement o = Document.get().createObjectElement();
      o.setWidth("100%");
      o.setHeight("100%");
      o.setData("/media/invoice1.pdf");
    
      // Attach the element to the document
      Document.get().getBody().appendChild(o);
    
      // Optionally you could wrap your element into a widget.
      Widget w = HTMLPanel.wrap(o);