A BrowserFrame is designed to display embedded web pages. It is the equivalent of the HTML iframe element.

gui browserFrame

Component’s XML-name: browserFrame

The component is implemented for Web Client.

An example of component definition in an XML-descriptor of a screen:

<browserFrame id="browserFrame"
    <url url="https://doc.cuba-platform.com/manual-6.6/"/>

Similarly to the Image component, the BrowserFrame component can also display images from different resources. You can set the resource type declaratively using the browserFrame elements listed below:

  • classpath - a resource in the classpath.

        <classpath path="com/company/sample/web/screens/myPic.jpg"/>
  • file - a resource in the file system.

        <file path="D:\sample\modules\web\web\VAADIN\images\myImage.jpg"/>
  • relativePath - resource in the application directory.

        <relativePath path="VAADIN/images/myImage.jpg"/>
  • theme - a theme resource, for example:

        <theme path="../halo/com.company.demo/myPic.jpg"/>
  • url - a resource which can be loaded from the given URL.

        <url url="http://www.foobar2000.org/"/>

browserFrame attributes:

  • alternateText - sets an alternate text for the frame in case the resource is not set or unavailable.

browserFrame resources settings:

  • bufferSize - the size of the download buffer in bytes used for this resource.

        <file bufferSize="1024" path="C:/img.png"/>
  • cacheTime - the length of cache expiration time in milliseconds.

        <file cacheTime="2400" path="C:/img.png"/>
  • mimeType - the MIME type of the resource.

        <url url="https://avatars3.githubusercontent.com/u/17548514?v=4&#38;s=200"

Methods of the BrowserFrame interface:

  • addSourceChangeListener() - adds a listener that will be notified when the content source is changed.

    browserFrame.addSourceChangeListener(event ->
            showNotification("Content updated"));
  • setSource() - sets the content source for the frame. The method accepts the resource type and returns the resource object that can be configured using the fluent interface. Each resource type has its own methods, for example, setPath() for ThemeResource type or setStreamSupplier() for StreamResource type:

    BrowserFrame frame = componentsFactory.createComponent(BrowserFrame.class);
    try {
        frame.setSource(UrlResource.class).setUrl(new URL("http://www.foobar2000.org/"));
    } catch (MalformedURLException e) {
        throw new RuntimeException(e);

    You can use the same resource types as for the Image component.

  • createResource() - creates the frame resource implementation by its type. The created object can be later passed to the setSource() method.

    UrlResource resource = browserFrame.createResource(UrlResource.class)
            .setUrl(new URL(fromString));
HTML markup in BrowserFrame:

BrowserFrame can be used to integrate HTML markup into your application. For example, you can dynamically generate HTML content at runtime from the user input.

<textArea id="textArea"
<browserFrame id="browserFrame"
textArea.addTextChangeListener(event -> {
    byte[] bytes = event.getText().getBytes(StandardCharsets.UTF_8);

            .setStreamSupplier(() -> new ByteArrayInputStream(bytes))
gui browserFrame 2
PDF in BrowserFrame:

Besides HTML, BrowserFrame can be also used for displaying PDF files content. Use the file as a resource and set the corresponding MIME type for it:

private BrowserFrame browserFrame;
private Resources resources;

public void init(Map<String, Object> params) {
            .setStreamSupplier(() -> resources.getResourceAsStream("/com/company/demo/" +
gui browserFrame 3

Attributes of browserFrame

align - alternateText - caption - colspan - description - enable - height - icon - id - responsive - rowspan - stylename - visible - width

Attributes of browserFrame resources

bufferSize - cacheTime - mimeType

Elements of browserFrame

classpath - file - relativePath - theme - url


addSourceChangeListener - createResource - setSource