iFrame with pure java

Is there a way to add an iFrame with pure java, like a Div, Span or Anchor.

I find it not under the following link:

https://vaadin.com/api/platform/12.0.3/com/vaadin/flow/component/HtmlContainer.html

But i find the code for iFrame on Gitthub under:

https://github.com/vaadin/flow/blob/master/flow-html-components/src/main/java/com/vaadin/flow/component/html/IFrame.java

I can not import it with:

import com.vaadin.flow.component.html.*;

If you look at https://github.com/vaadin/flow/blob/master/flow-html-components/src/main/java/com/vaadin/flow/component/html/IFrame.java#L31 , you’ll see IFrame is included starting from Flow 1.3, which is currently in alpha stage: https://github.com/vaadin/flow/releases

ohhhh
i understand.

Thanks.

Hans,

Here’s a very basic Iframe:

package bc.ui.components;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.HasSize;
import com.vaadin.flow.component.Tag;

@SuppressWarnings("serial")
@Tag("iframe")
public class Iframe extends Component implements HasSize {

   public Iframe() {
   }

   public Iframe(String src) {
      setSrc(src);
   }

   public void setSrc(String src) {
      getElement().setProperty("src", src);
   }
}

Or you could also just copy-paste the class from GitHub, it doesn’t seem to have any dependencies.

When i try to add the code from GitHub all is ok, but i get one error at line

@Tag(Tag.IFRAME)

The error is

IFRAME cannot be resolved or is not a field

I try to make a workaround with

@Tag(value = "IFrame")

Now it works but i dont know if it is ok

When i use now this iFrame like in my other Posting here with “MIcroservice with iFrame”.

I have the same problem like there.

@Tag("iframe") should work at least.

You can use HTML5 for this:


  **<link rel="import" href="/path/to/file.html">**

Using HTML5 is ok

<link rel="import" href="/path/to/file.html">

But how can i include webside with HTML5 from extern

Something like

<link rel="import" href="http://www.google.com">