vaadinvaadin-flowvaadin24

Vaadin 24 export component to embed into another HTML page


In my Vaadin Flow 24 application, I have a view:

@Route(value = "embedded/jobables/recent")
@AnonymousAllowed
public class RecentJobablesEmbeddedView extends VerticalLayout implements HasUrlParameter<String> {
...
}

which is also component(extended from VerticalLayout).

I'd like to export this component to be able to embed it into non-Vaadin HTML page.

I created the following exporter class:

public class RecentJobablesEmbeddedExporter extends WebComponentExporter<RecentJobablesEmbeddedView> {

    protected RecentJobablesEmbeddedExporter(String tag) {
        super("recent-jobables-embedded-view");
    }

    @Override
    protected void configureInstance(WebComponent<RecentJobablesEmbeddedView> webComponent, RecentJobablesEmbeddedView recentJobablesEmbeddedView) {

    }

}

Right now I'm unable to access:

http://localhost:8080/vaadin/web-component/recent-jobables-embedded-view.js

Vaadin flow application returns 404 Page Not Found.

What am I doing wrong and how to fix it?


Solution

  • The WebComponentExporter implementation must have a public default constructor. In your sample code, it is protected and it takes an argument.

    If you check the server logs, you should see a message like

    Class RecentJobablesEmbeddedExporter has no public no-argument constructor, and won't be instantiated as a 'WebComponentExporter' by default