Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
Vaadin 23 JavaScript import issue

I have java class which extends the Vaadin Div class, which should be a cookie warning popup (implementation is not yet complete):

//imports

@CssImport("css/info_popup.css")
@JsModule("js/script.js")
@Tag("info_popup")
public class CookiesDiv extends Div {

    public CookiesDiv() {
        this.setId("info_popup");

        Span span = new Span("By continuing to this site, you accept the EULA and the cookies. ");
        span.add(new Anchor("./info", "Learn more"));
        this.add(span);

        this.add(new Button("GOT IT", event -> {
            Page page = UI.getCurrent().getPage();
            this.getId().ifPresent(id -> page.executeJs("fadeOut('" + id + "')"));
        }));
    }
}

When the 'GOT IT' button is pressed, a JS function written in the 'script.js' is called, which animates the div and then removes it from the page:

window.fadeOut = function(target) {
    target.style = 'animation: fade-out 0.5s ease-out 0s forwards'
    setTimeout(function() {
        target.style = 'display: none'
    }, 500)
}

My issue is: the file is successfully imported, but when I test the button the browser console throws the following error: "Uncaught ReferenceError: fadeOut is not defined".

I read some forums which said that in Vaadin 14 changing function fadeOut(target) {} to window.fadeOut = function(target) {} works, but feels like nothing changed.

This is my main tree:

main
├───java
│   └───com
│       └───Achille004
│           └───FreeTransfer
│               ├───backend
│               │   ├───database
│               │   ├───handlers
│               │   └───security
│               └───frontend
│                   ├───css
│                   ├───js
│                   ├───pages
│                   └───views
└───resources
    ├───META-INF
    │   └───resources
    │       └───img
    ├───static
    └───templates

CookiesDiv.java is located into pages and css and js modules are in their own folder.

I could not find other stuff online, so I am just lost. Does someone know how to fix?

P.S. I do not know if it could help: most of the proprieties in the CSS file are ignored, but I still have to do some research about it.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your imports should be

@CssImport("./css/info_popup.css")
@JsModule("./js/script.js")
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda