LoadScriptStrategy doesnt download JS for custom components
jfoundation Nov 1, 2009 6:47 AMHi,
Need help ASAP - Have to move app to production :(
Problem :
Load script and style strategy if set to ALL
JS related to our custom components are not getting downloaded.
how do we enable the dowload of js related to custom components also in a single integrated script file ?
web.xml has following entries
<context-param> <param-name>org.richfaces.LoadStyleStrategy</param-name> <param-value>ALL</param-value> </context-param> <context-param> <param-name>org.richfaces.LoadScriptStrategy</param-name> <param-value>ALL</param-value> </context-param>
Custom components :
The renderers for our custom components extend the Richfaces Composite renderer class and overrides the required methods
public class JmLovRenderer extends CompositeRenderer { ..... private final InternetResource[] styles = { getResource("/css/lov/lovstyles.css") }; private final InternetResource[] scripts = { getResource("/javascript/lov/JMainLib.js"), getResource("/javascript/lov/JLov.js"), getResource("/javascript/lov/domRelated.js"), getResource("/javascript/lov/JProperties.js"), getResource("/javascript/lov/jfweblov.js"), getResource("/javascript/lov/JValidation.js"), getResource("/javascript/lov/domRelated.js") }; .. ... .. @Override protected InternetResource[] getStyles() { synchronized (this) { if (stylesAll == null) { InternetResource[] rsrcs = super.getStyles(); boolean ignoreSuper = rsrcs == null || rsrcs.length == 0; boolean ignoreThis = styles == null || styles.length == 0; if (ignoreSuper) { if (ignoreThis) { stylesAll = new InternetResource[0]; System.out.println("******** If StylesAll : "+stylesAll); } else { stylesAll = styles; for(int it=0;it < stylesAll.length ;it++) System.out.println("******** Else StylesAll : "+stylesAll[it]); } } else { if (ignoreThis) { stylesAll = rsrcs; } else { java.util.Set rsrcsSet = new java.util.LinkedHashSet(); for (int i = 0; i < rsrcs.length; i++) { rsrcsSet.add(rsrcs); } for (int i = 0; i < styles.length; i++) { rsrcsSet.add(styles); } stylesAll = (InternetResource[]) rsrcsSet .toArray(new InternetResource[rsrcsSet.size()]); } } } } return stylesAll; } @Override protected InternetResource[] getScripts() { synchronized (this) { if (scriptsAll == null) { InternetResource[] rsrcs = super.getScripts(); boolean ignoreSuper = rsrcs == null || rsrcs.length == 0; boolean ignoreThis = scripts == null || scripts.length == 0; if (ignoreSuper) { if (ignoreThis) { scriptsAll = new InternetResource[0]; } else { scriptsAll = scripts; } } else { if (ignoreThis) { scriptsAll = rsrcs; } else { java.util.Set rsrcsSet = new java.util.LinkedHashSet(); for (int i = 0; i < rsrcs.length; i++) { rsrcsSet.add(rsrcs); } for (int i = 0; i < scripts.length; i++) { rsrcsSet.add(scripts); } scriptsAll = (InternetResource[]) rsrcsSet .toArray(new InternetResource[rsrcsSet.size()]); } } } } return scriptsAll; }