public class ScriptRenderer extends RendererBase {
public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
super.prepareRender(facesContext, component);
if (facesContext instanceof TobagoFacesContext) {
TobagoFacesContext pageFacesContext = (TobagoFacesContext) facesContext;
UIScript scriptComponent = (UIScript) component;
String exit = scriptComponent.getOnexit();
if (exit != null) {
pageFacesContext.getOnexitScripts().add(exit);
}
String submit = scriptComponent.getOnsubmit();
if (submit != null) {
pageFacesContext.getOnsubmitScripts().add(submit);
}
String load = scriptComponent.getOnload();
if (load != null) {
pageFacesContext.getOnloadScripts().add(load);
}
String unload = scriptComponent.getOnunload();
if (unload != null) {
pageFacesContext.getOnunloadScripts().add(unload);
}
String script = scriptComponent.getScript();
if (script != null) {
pageFacesContext.getScriptBlocks().add(script);
}
String file = scriptComponent.getFile();
if (file != null) {
pageFacesContext.getScriptFiles().add(file);
}
}
}