I had to include a HTML page in my ADF application. The HTML page contains carousel and has references to javascript files which control it. I’ve found different ways to do this.
Here are some of them:
  –  using jsp:include
<jsp:include page="/includes/myIncludeFragment.jsff">
     <jsp:param name="myParam"  value="myValue"/>
</jsp:include>
– using af:declarativeComponent
<af:declarativeComponent id="dc0" viewId="/includes/myIncludeFragment.jsff" myParam="myValue"/>
– using ui:include
<ui:include src="/WEB-INF/myIncludeFragment.jsff" />
I’ve decided to use the af:declarativeComponent which is placed inside an af:showDetailItem of an af:panelTabbed. So I have added the HTML page. Everything was perfect when I opened it, but after I opened a new tab and returned to the first one – the slider disappeared. After a short research I found that there are two javascript files and the second one is used by the first one, so the first javascript file cannot find a method which is declared in the second one.
I’ve changed the order and the slider started to work in this case but when I pressed over opened tab and returned to the first one with included slider, it didn’t work. Finally, I found that the javascript didn’t load in this case so, I had to load it every time when I open this tab. I made it programmatically. I created a text filed in this page and I used its get method to load the javascript.
Every time I`ve opened the page, the get method is called and executes the code to load the javascript files. Here is the code:
[javascript]
public String getSliderJavascript(){
FacesContext fctx = FacesContext.getCurrentInstance();
ExtendedRenderKitService erks = null;
erks = Service.getRenderKitService(fctx, ExtendedRenderKitService.class);
erks.addScript(fctx, carouselJS);
erks.addScript(fctx, mainJS);
return null;
}
public void setSliderJavascript(String s){
return;
}
private static String getSliderJavascript(String name) {
String path
= FacesContext.getCurrentInstance().getExternalContext().getRealPath(name).toString().trim();
String script
= FileUtils.read(path);
return script;
}
[/javascript]
Finally everything works perfectly.