NIHVIVO-2164 Fix jsp compile errors in propDelete.jsp. Some refactoring.
This commit is contained in:
parent
428e917de9
commit
3cbc60d357
8 changed files with 30 additions and 25 deletions
|
@ -34,7 +34,7 @@ public class FreemarkerComponentGenerator extends FreemarkerHttpServlet {
|
|||
|
||||
// Mimic what FreemarkerHttpServlet does for a new request
|
||||
VitroRequest vreq = new VitroRequest(request);
|
||||
VitroFreemarkerConfiguration config = getConfig(vreq);
|
||||
FreemarkerConfiguration config = getConfig(vreq);
|
||||
vreq.setAttribute("freemarkerConfig", config);
|
||||
config.resetRequestSpecificSharedVariables();
|
||||
Map<String, Object> map = getPageTemplateValues(vreq);
|
||||
|
|
|
@ -34,9 +34,9 @@ import freemarker.template.TemplateException;
|
|||
import freemarker.template.TemplateModel;
|
||||
import freemarker.template.TemplateModelException;
|
||||
|
||||
public class VitroFreemarkerConfiguration extends Configuration {
|
||||
public class FreemarkerConfiguration extends Configuration {
|
||||
|
||||
private static final Log log = LogFactory.getLog(VitroFreemarkerConfiguration.class);
|
||||
private static final Log log = LogFactory.getLog(FreemarkerConfiguration.class);
|
||||
|
||||
private final String themeDir;
|
||||
private final ServletContext context;
|
||||
|
@ -46,7 +46,7 @@ public class VitroFreemarkerConfiguration extends Configuration {
|
|||
private final Tags scripts;
|
||||
private final Tags headScripts;
|
||||
|
||||
VitroFreemarkerConfiguration(String themeDir, VitroRequest vreq, ServletContext context) {
|
||||
FreemarkerConfiguration(String themeDir, VitroRequest vreq, ServletContext context) {
|
||||
|
||||
this.themeDir = themeDir;
|
||||
this.context = context;
|
||||
|
@ -103,8 +103,12 @@ public class VitroFreemarkerConfiguration extends Configuration {
|
|||
/** Some template variables are shared so that they are accessible to
|
||||
* all templates, but they are request-specific and so need to be
|
||||
* reset at the beginning of a new request.
|
||||
*
|
||||
* This is public for now because it's accessed by propDelete.jsp.
|
||||
* Once the property deletion is integrated into Freemarker and generated
|
||||
* with a Freemarker page, the visibility can be reduced to package.
|
||||
*/
|
||||
void resetRequestSpecificSharedVariables() {
|
||||
public void resetRequestSpecificSharedVariables() {
|
||||
stylesheets.reset();
|
||||
scripts.reset();
|
||||
headScripts.reset();
|
|
@ -42,7 +42,7 @@ public class FreemarkerConfigurationLoader {
|
|||
}
|
||||
}
|
||||
|
||||
public VitroFreemarkerConfiguration getConfig(VitroRequest vreq) {
|
||||
public FreemarkerConfiguration getConfig(VitroRequest vreq) {
|
||||
String themeDir = getThemeDir(vreq.getAppBean());
|
||||
return getConfigForTheme(themeDir, vreq);
|
||||
}
|
||||
|
@ -63,15 +63,15 @@ public class FreemarkerConfigurationLoader {
|
|||
}
|
||||
|
||||
|
||||
protected VitroFreemarkerConfiguration getConfigForTheme(String themeDir, VitroRequest vreq) {
|
||||
protected FreemarkerConfiguration getConfigForTheme(String themeDir, VitroRequest vreq) {
|
||||
|
||||
/* The Configuration is theme-specific because:
|
||||
* 1. The template loader is theme-specific, since it specifies a theme directory to load templates from.
|
||||
* 2. Shared variables like stylesheets are theme-specific.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, VitroFreemarkerConfiguration> themeToConfigMap =
|
||||
(Map<String, VitroFreemarkerConfiguration>) context.getAttribute("themeToConfigMap");
|
||||
Map<String, FreemarkerConfiguration> themeToConfigMap =
|
||||
(Map<String, FreemarkerConfiguration>) context.getAttribute("themeToConfigMap");
|
||||
|
||||
if( themeToConfigMap == null ) {
|
||||
log.error("The templating system is not configured correctly. Make sure that you have the FreemarkerSetup context listener in your web.xml.");
|
||||
|
@ -81,7 +81,7 @@ public class FreemarkerConfigurationLoader {
|
|||
} else if (themeToConfigMap.containsKey(themeDir)) {
|
||||
return themeToConfigMap.get(themeDir);
|
||||
} else {
|
||||
VitroFreemarkerConfiguration config = new VitroFreemarkerConfiguration(themeDir, vreq, context);
|
||||
FreemarkerConfiguration config = new FreemarkerConfiguration(themeDir, vreq, context);
|
||||
themeToConfigMap.put(themeDir, config);
|
||||
return config;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
|||
return;
|
||||
}
|
||||
|
||||
VitroFreemarkerConfiguration config = getConfig(vreq);
|
||||
FreemarkerConfiguration config = getConfig(vreq);
|
||||
vreq.setAttribute("freemarkerConfig", config);
|
||||
config.resetRequestSpecificSharedVariables();
|
||||
|
||||
|
@ -124,7 +124,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
|||
doGet(request, response);
|
||||
}
|
||||
|
||||
protected VitroFreemarkerConfiguration getConfig(VitroRequest vreq) {
|
||||
protected FreemarkerConfiguration getConfig(VitroRequest vreq) {
|
||||
FreemarkerConfigurationLoader loader =
|
||||
FreemarkerConfigurationLoader.getFreemarkerConfigurationLoader(getServletContext());
|
||||
return loader.getConfig(vreq);
|
||||
|
@ -270,7 +270,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
|||
*/
|
||||
private void setRequestUrls(VitroRequest vreq) {
|
||||
|
||||
VitroFreemarkerConfiguration config = (VitroFreemarkerConfiguration)vreq.getAttribute("freemarkerConfig");
|
||||
FreemarkerConfiguration config = (FreemarkerConfiguration)vreq.getAttribute("freemarkerConfig");
|
||||
TemplateModel urlModel = config.getSharedVariable("urls");
|
||||
|
||||
try {
|
||||
|
|
|
@ -26,7 +26,7 @@ public class FreemarkerSetup implements ServletContextListener {
|
|||
}
|
||||
|
||||
ServletContext sc = event.getServletContext();
|
||||
sc.setAttribute("themeToConfigMap", new HashMap<String, VitroFreemarkerConfiguration>());
|
||||
sc.setAttribute("themeToConfigMap", new HashMap<String, FreemarkerConfiguration>());
|
||||
BaseTemplateModel.setServletContext(sc);
|
||||
FreemarkerComponentGenerator.setServletContext(sc);
|
||||
UrlBuilder.contextPath = sc.getContextPath();
|
||||
|
|
|
@ -17,7 +17,7 @@ import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
|
|||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.ResourceFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.VitroFreemarkerConfiguration;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerConfiguration;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field;
|
||||
|
@ -109,8 +109,7 @@ public class DateTimeWithPrecision extends BaseEditElement {
|
|||
@Override
|
||||
public String draw(String fieldName, EditConfiguration editConfig,
|
||||
EditSubmission editSub, Configuration fmConfig) {
|
||||
Map map = getMapForTemplate( editConfig, editSub);
|
||||
//map.putAll( VitroFreemarkerConfiguration.getDirectives());
|
||||
Map map = getMapForTemplate( editConfig, editSub);
|
||||
return merge( fmConfig, TEMPLATE_NAME, map);
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,6 @@ public class FreemarkerEmailMessage {
|
|||
}
|
||||
|
||||
public void processTemplate() {
|
||||
//bodyMap.putAll(FreemarkerHttpServlet.getDirectivesForAllEnvironments());
|
||||
bodyMap.put("email", new EmailDirective(this));
|
||||
|
||||
try {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
<%@page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
||||
<%@page import="edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel" %>
|
||||
<%@page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerConfigurationLoader"%>
|
||||
<%@page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerConfiguration" %>
|
||||
<%@page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet"%>
|
||||
<%@page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.TemplateProcessingHelper"%>
|
||||
|
||||
|
@ -98,9 +99,7 @@ public WebappDaoFactory getUnfilteredDaoFactory() {
|
|||
if( subject == null ) throw new Error("could not find subject " + subjectUri);
|
||||
request.setAttribute("subjectName",subject.getName());
|
||||
|
||||
// Get the statement data to display
|
||||
// rjy7 Alternative implementation: have the template put the markup into a url or form param
|
||||
// which can then just be spit out here.
|
||||
// Get the statement data to be displayed
|
||||
String templateName = request.getParameter("templateName");
|
||||
Map params = request.getParameterMap();
|
||||
Map<String, String> statement = new HashMap<String, String>();
|
||||
|
@ -121,16 +120,20 @@ public WebappDaoFactory getUnfilteredDaoFactory() {
|
|||
|
||||
/* Some propStatements (propStatement-educationalTraining.ftl) make reference to the individual,
|
||||
* but instead of adding it to the data model we'll test in the template for non-existence. If
|
||||
* this becomes more common, add it here instead.
|
||||
* this becomes more common, add it here instead. We don't want to generate the property
|
||||
* list for the individual, though, so should modify IndividualTemplateModel to make that
|
||||
* conditional, or perhaps use a different template model that contains only the limited
|
||||
* information needed in the propStatement templates.
|
||||
*/
|
||||
//map.put("individual", new IndividualTemplateModel(subject, vreq));
|
||||
|
||||
map.putAll(FreemarkerHttpServlet.getDirectives());
|
||||
map.putAll(FreemarkerHttpServlet.getMethods());
|
||||
//map.putAll(FreemarkerHttpServlet.getDirectives());
|
||||
//map.putAll(FreemarkerHttpServlet.getMethods());
|
||||
ServletContext context = getServletContext();
|
||||
FreemarkerConfigurationLoader loader =
|
||||
FreemarkerConfigurationLoader.getFreemarkerConfigurationLoader(context);
|
||||
Configuration fmConfig = loader.getConfig(vreq);
|
||||
FreemarkerConfiguration fmConfig = loader.getConfig(vreq);
|
||||
fmConfig.resetRequestSpecificSharedVariables();
|
||||
TemplateProcessingHelper helper = new TemplateProcessingHelper(fmConfig, vreq, context);
|
||||
statementDisplay = helper.processTemplateToString(templateName, map);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue