JavaScript extension for UI

I need something similar (attach a JS code to CUBA) and your example was very useful. I managed to put my js function bounded to the button of this example and it works fine.

My question is: is it possible to bound the javascript extension not to a button but to the screen in general ? I don’t want to show a button, just call the extension at any time without bounding it to a button.

Thanks,

Alejandro

Hi,

Yes, you can bind your extension to the top layout of the screen. It could be just:

com.vaadin.ui.Component vLayout = unwrap(com.vaadin.ui.Component.class);

// create client-side extension and add it to vLayout
new MyExtension().extend(vLayout);

In 7.0+ version you can unwrap window:

com.vaadin.ui.Component vLayout = getWindow().unwrap(com.vaadin.ui.Component.class);
new MyExtension().extend(vLayout);
1 Like