Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

157
Visualizações
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 Respostas
Responde à pergunta

0

Your imports should be

@CssImport("./css/info_popup.css")
@JsModule("./js/script.js")
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda