21/02/2017
getExternalResources
When you create a new component (extends AbstractVisualComponent) you can ask resource like js or css, this ressources will be only integrated to HTML if your component is in the page.
Exemples
externals resources
@Override
public Collection<String> getExternalResources(ContentContext ctx) {
Collection<String> outRes = new LinkedList<String>();
outRes.add("https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js");
return outRes;
}
Resources from template
@Override
public Collection<String> getExternalResources(ContentContext ctx) {
Collection<String> outRes = new LinkedList<String>();
Template tpl = ctx.getCurrentTemplate();
outRes.add(URLHelper.createStaticTemplateURLWithoutContext(ctx, tpl, "/js/chartist.min.css"));
return outRes;
}