diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/dump/DumpDirective.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/dump/DumpDirective.java index 30449c0c2..d070dc338 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/dump/DumpDirective.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/directives/dump/DumpDirective.java @@ -47,7 +47,7 @@ public class DumpDirective extends BaseTemplateDirectiveModel { String var = ((SimpleScalar)o).getAsString(); DumpHelper helper = new DumpHelper(env); - Map map = helper.getVariableDumpData(var); + Map map = new HashMap(); map.put("var", helper.getVariableDump(var)); TemplateHashModel dataModel = env.getDataModel(); 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 7ec1ec62a..a92218c1a 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 @@ -51,11 +51,8 @@ public class DumpHelper { Map map = new HashMap(); map.put("var", varName); - if (tm != null) { - - // Just use toString() method for now. Handles nested collections. Could make more sophisticated later. + if (tm != null) { String type = null; - String value = tm.toString(); Object unwrappedModel = null; try { @@ -63,7 +60,12 @@ public class DumpHelper { } catch (TemplateModelException e) { log.error("Cannot unwrap template model " + varName + "."); } - + + // Just use toString() method for now. Handles nested collections. Could make more sophisticated later. + // tm.toString() gives wrong results in the case of, e.g., a boolean value in a hash. tm.toString() may + // return a TemplateBooleanModel object, while unwrappedModel.toString() returns "true" or "false." + String value = unwrappedModel.toString(); // tm.toString(); + // This case must precede the TemplateScalarModel case, because // tm is an instance of StringModel and thus a TemplateScalarModel. if (unwrappedModel instanceof BaseTemplateModel) {