}
public void generate(PrintWriter anOutputWriter, Map aValues, PrintWriter aLogger) throws GeneratorException {
- aLogger.println("processing...<br/>");
- template.process((TemplateModelRoot) makeMapAdapter(aValues), anOutputWriter);
- aLogger.println("processed...<br/>");
+ try {
+ template.process((TemplateModelRoot) makeMapAdapter(aValues), anOutputWriter);
+ }
+ catch (Throwable t) {
+ aLogger.println("Exception occurred: "+t.getMessage());
+ t.printStackTrace(aLogger);
+ }
}
private static TemplateScalarModel makeStringAdapter(String aString) {
if (!valuesCache.containsKey(aKey)) {
Object value = map.get(aKey);
-// ML: this unfortunately doesn't work, because the entity doesn't seem to store
-// fields with null values
-// if (value == null && !map.containsKey(aKey))
-// throw new TemplateModelException("MapAdapter: no key "+aKey+" available");
+ if (value == null && !map.containsKey(aKey))
+ throw new TemplateModelException("MapAdapter: no key "+aKey+" available");
valuesCache.put(aKey, makeAdapter(value));
}
position=0;
}
}
-
-/* private static class DateAdapter implements TemplateHashModel {
- Date date;
-
- private DateAdapter(Date aDate) {
- date = aDate;
- }
-
- public boolean isEmpty() {
- return false;
- }
-
- public TemplateModel get(String aKey) throws TemplateModelException {
- return makeAdapter(new SimpleDateFormat(aKey).format(date));
- }
- }
-*/
}