@Override public void configureModel(PageContext pageContext) { for (Resource resource : resources) { if (resource.getCategory() != null) { pageContext.includeResource(resource); } else { log.warn( GlobalResourceIncluder.class.getName() + " is trying to include a resource with no category: " + resource.getProviderName() + ":" + resource.getResourcePath()); } } }
private String toHtml(String body, PageContext context) { StringBuilder ret = new StringBuilder(); ret.append("<?xml version=\"1.0\"?>\n"); ret.append( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"); ret.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"); ret.append("<head>\n"); if (context.getPageTitle() != null) { ret.append("<title>" + context.getPageTitle() + "</title>\n"); } else { ret.append("<title>OpenMRS</title>\n"); } ret.append( "<link rel=\"shortcut icon\" type=\"image/ico\" href=\"/" + WebConstants.CONTEXT_PATH + "/images/openmrs-favicon.ico\">\n"); ret.append( "<link rel=\"icon\" type=\"image/png\" href=\"/" + WebConstants.CONTEXT_PATH + "/images/openmrs-favicon.png\">\n"); for (Resource resource : context.getJavascriptToInclude()) { ret.append( "<script type=\"text/javascript\" src=\"/" + WebConstants.CONTEXT_PATH + "/ms/uiframework/resource/" + resource.getProviderName() + "/" + resource.getResourcePath() + "\"></script>\n"); } for (Resource resource : context.getCssToInclude()) { ret.append( "<link rel=\"stylesheet\" href=\"/" + WebConstants.CONTEXT_PATH + "/ms/uiframework/resource/" + resource.getProviderName() + "/" + resource.getResourcePath() + "\" type=\"text/css\"/>\n"); } ret.append("</head>\n"); ret.append("<body>\n"); ret.append("<script>var OPENMRS_CONTEXT_PATH = '" + WebConstants.CONTEXT_PATH + "';</script>"); ret.append(body); ret.append("</body>\n"); ret.append("</html>"); return ret.toString(); }