diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/dump/DumpHelper.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/dump/DumpHelper.java index bf84736dd..7a92fa74f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/dump/DumpHelper.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/dump/DumpHelper.java @@ -213,54 +213,11 @@ public class DumpHelper { } private Map getTemplateModelValues(TemplateModel wrappedModel, BaseTemplateModel unwrappedModel) { - - Map map = new HashMap(); - map.put("value", unwrappedModel.dump()); - int exposureLevel = getExposureLevel(wrappedModel, unwrappedModel.getClass()); - List publicMethods = getMethodsAvailableToTemplate(exposureLevel, unwrappedModel.getClass()); - Map properties = new HashMap(); - List methods = new ArrayList(); - for (Method method : publicMethods) { - // Don't include the dump method, since this is used above to provide the value of the object. - if (method.getName().equals("dump")) { - continue; - } - String key = getMethodDisplayName(method); - if (key.endsWith(")")) { - methods.add(key); - } else { - try { - Object result = method.invoke(unwrappedModel); - String value; - if (result == null) { - value = "null"; - } else if (result instanceof BaseTemplateModel) { - value = getTemplateModelDump((BaseTemplateModel)result, exposureLevel); - } else { - // Don't use ?html in the template, because then the output of - // getTemplateModelDump, which is html, gets escaped too. - value = StringEscapeUtils.escapeHtml(result.toString()); - } - properties.put(key, value); - } catch (Exception e) { - log.error(e, e); - continue; - } - } - } - - map.put("properties", properties); - map.put("methods", methods); - return map; + return getTemplateModelValues(unwrappedModel, exposureLevel); } - private String getTemplateModelDump(BaseTemplateModel model, int exposureLevel) { - // What we need to do here is recurse down into the model and display the value, type, - // properties, and methods for each one. Pull out the part shared by this and getTemplateModelValues - // into a common method. This will return the string so that the template doesn't have to follow - // the recursion. - + private Map getTemplateModelValues(BaseTemplateModel model, int exposureLevel) { Map map = new HashMap(); map.put("value", model.dump()); @@ -299,7 +256,11 @@ public class DumpHelper { map.put("type", model.getClass().getName()); map.put("properties", properties); map.put("methods", methods); - + return map; + } + + private String getTemplateModelDump(BaseTemplateModel model, int exposureLevel) { + Map map = getTemplateModelValues(model, exposureLevel); return BaseTemplateDirectiveModel.processTemplateToString("dump-var.ftl", map, env); } diff --git a/webapp/web/templates/freemarker/body/partials/dump/dump-var.ftl b/webapp/web/templates/freemarker/body/partials/dump/dump-var.ftl index d95fad25f..fa3845942 100644 --- a/webapp/web/templates/freemarker/body/partials/dump/dump-var.ftl +++ b/webapp/web/templates/freemarker/body/partials/dump/dump-var.ftl @@ -4,7 +4,7 @@
<#if var??> <#-- not defined for a nested template model object --> -

Variable name: ${var}

+

Variable name: ${var}

<#if value??>