}
@Override
public Object render(URL url, Map<String, Object> inputData) throws RendererException {
if (velocityTemplate == null) {
throw new RendererException("Couldn't find index.vm");
}
synchronized (this) {
if (template == null) {
template = engine.getTemplate("index.vm");
}
}
try {
String formContent = IOUtils.toString(url.openStream());
JsonObject json = new JsonObject();
json.addProperty("formjson", formContent);
String contextPath = (String) inputData.remove(BASE_CONTEXT_PATH);
json.add("formData", toJsonObject(inputData));
json.addProperty("contextPath", contextPath);
VelocityContext context = new VelocityContext();
context.put("contextPath", contextPath);
context.put("formContent", json.toString());
StringWriter writer = new StringWriter();
template.merge(context, writer);
return writer.toString();
} catch (IOException e) {
throw new RendererException("Problem reading index.vm", e);
}
}