When you're adding widgets on the fly programmatically for the first time (ex : new PaperButton x5 in a for)
the import is imported multiple time because the href is not fully loaded between each instanciation.
urlImported.add(href); should be added directly to avoid the issue.
Maybe remove it if the script fail to load ?
public static void importHref(String hrefOrTag, final Function ok, Function err) {
if (!hrefOrTag.startsWith("http")) {
// It's a tag
if (hrefOrTag.matches("[\w-]+")) {
hrefOrTag = hrefOrTag + "/" + hrefOrTag + ".html";
}
// It's not prefixed with the bower_components convention
if (!hrefOrTag.startsWith("bower_components")) {
hrefOrTag = "bower_components/" + hrefOrTag;
}
hrefOrTag = GWT.getModuleBaseForStaticFiles() + hrefOrTag;
}
if (!urlImported.contains(hrefOrTag)) {
final String href = hrefOrTag;
importHrefImpl(href, new Function() {
public Object call(Object arg) {
// Don't update the list until the import is actually loaded
urlImported.add(href);
if (ok != null) {
ok.call(arg);
}
return null;
}
}, err);
} else if (ok != null) {
ok.call(hrefOrTag);
}
}
When you're adding widgets on the fly programmatically for the first time (ex : new PaperButton x5 in a for) the import is imported multiple time because the href is not fully loaded between each instanciation. urlImported.add(href); should be added directly to avoid the issue. Maybe remove it if the script fail to load ?
public static void importHref(String hrefOrTag, final Function ok, Function err) { if (!hrefOrTag.startsWith("http")) { // It's a tag if (hrefOrTag.matches("[\w-]+")) { hrefOrTag = hrefOrTag + "/" + hrefOrTag + ".html"; } // It's not prefixed with the bower_components convention if (!hrefOrTag.startsWith("bower_components")) { hrefOrTag = "bower_components/" + hrefOrTag; } hrefOrTag = GWT.getModuleBaseForStaticFiles() + hrefOrTag; } if (!urlImported.contains(hrefOrTag)) { final String href = hrefOrTag; importHrefImpl(href, new Function() { public Object call(Object arg) { // Don't update the list until the import is actually loaded urlImported.add(href); if (ok != null) { ok.call(arg); } return null; } }, err); } else if (ok != null) { ok.call(hrefOrTag); } }