Changed template variable stylesheetDir to themeStylesheetDir for clarity. Added examples of how to add a script from a body template. Pass themedir to ScriptList object.

This commit is contained in:
rjy7 2010-06-25 17:44:50 +00:00
parent 2ada3b7c35
commit df683191cf
4 changed files with 30 additions and 6 deletions

View file

@ -209,10 +209,10 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
// This value will be available to any template as a path for adding a new stylesheet.
// It does not contain the context path, because the methods to generate the href
// attribute from the string passed in by the template automatically add the context path.
map.put("stylesheetDir", themeDir + "/css");
map.put("themeStylesheetDir", themeDir + "/css");
map.put("stylesheets", getStylesheetList(themeDir));
map.put("scripts", getScriptList());
map.put("scripts", getScriptList(themeDir));
addDirectives(map);
@ -262,14 +262,14 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
}
}
private TemplateModel getScriptList() {
private TemplateModel getScriptList(String themeDir) {
// For script and stylesheet lists, use an object wrapper that exposes write methods,
// instead of the configuration's object wrapper, which doesn't. The templates can
// add stylesheets and scripts to the lists by calling their add() methods.
BeansWrapper wrapper = new DefaultObjectWrapper();
try {
return wrapper.wrap(new ScriptList());
return wrapper.wrap(new ScriptList(themeDir));
} catch (TemplateModelException e) {
log.error("Error creating script TemplateModel");
return null;

View file

@ -101,7 +101,7 @@ public class AutocompleteController extends FreeMarkerHttpServlet implements Sea
try {
// make sure an IndividualDao is available
// make sure an IndividualDao is available
if( vreq.getWebappDaoFactory() == null
|| vreq.getWebappDaoFactory().getIndividualDao() == null ){
log.error("makeUsableBeans() could not get IndividualDao ");
@ -120,7 +120,11 @@ public class AutocompleteController extends FreeMarkerHttpServlet implements Sea
log.debug("query for '" + qtxt +"' is " + query.toString());
// Get the list of uris that should be excluded from the results
List<String> urisToExclude = Arrays.asList(vreq.getParameterValues("filter"));
String filters[] = vreq.getParameterValues("filter");
List<String> urisToExclude = new ArrayList<String>();
if (filters != null) {
urisToExclude = Arrays.asList(vreq.getParameterValues("filter"));
}
if (query == null ) {
doNoQuery(templateName, map, config, response);