public class MyStuff extends Div {
public MyStuff() {}
boolean loaded = ui.getElement().getProperty("mystuff-loaded", false);
if(!loaded) {
ui.getPage().addJavaScript("/some/local/path/mystuff.js");
ui.getElement().setProperty("mystuff-loaded", true);
}
}
}
I’ve generalized this to a loadJs(String path) which loads the path and also use the path as property name.
This works fine in both Firefox and Chrome, but I feel a bit uneasy about it.
Does anyone know if there are any limitations on a “property” name, or is it just a string in a hash table?
But I’m unclear on what that is
If it is a regular javascript object property, then I assume almost anything is ok.
So, I can do ui.getElement.setProperty(“>”, true) without breaking anything?
“>” was just there to take it to the extreme, to understand what the limits are, if any. For now I’ll assume it is a javascript object property, ie a hash-key, and that almost anything is allowed, even “>”, and certainly a resource path, so there should be no issue doing:
That seems to me overkill. How many JavaScript files are you loading? You can use one flag for all the JavaScript files. Maybe @quintessential-ibex knows the answer.
We have hundreds of screens. Most using just regular Vaadin components, but a handful use Highchart, both regular and Gantt, and Leaflet Map.
Now that we are free from the yoke that was GWT I can easily imagine us using other javascript frameworks as well. Hopefully through Web Components, and ready-made Vaadin integration, but I can’t assume that.
I haven’t written the screen, so I have no idea which of these can be considered part of the same “package”, so it is less error-prone to have a flag for each.
I assume this could be “frontended”, but I just want to get stuff done.