jsonResponse.put("_urlWidgetHtml", string.toString());
}
// Evaluate all dynamic texts.
List<String> dynamicTexts = new ArrayList<String>();
JspFactory jspFactory = JspFactory.getDefaultFactory();
PageContext pageContext = jspFactory.getPageContext(this, page.getRequest(), page.getResponse(), null, false, 0, false);
try {
ExpressionFactory expressionFactory = jspFactory.getJspApplicationContext(getServletContext()).getExpressionFactory();
ELContext elContext = pageContext.getELContext();
List<UUID> contentIds = page.params(UUID.class, "_dti");
int contentIdsSize = contentIds.size();
List<String> templates = page.params(String.class, "_dtt");
for (int i = 0, size = templates.size(); i < size; ++ i) {
try {
Object content = i < contentIdsSize ? findContent(object, contentIds.get(i)) : null;
if (content != null) {
pageContext.setAttribute("content", content);
dynamicTexts.add(((String) expressionFactory.createValueExpression(elContext, templates.get(i), String.class).getValue(elContext)));
} else {
dynamicTexts.add(null);
}
} catch (RuntimeException error) {
if (Settings.isProduction()) {
dynamicTexts.add("");
} else {
StringWriter string = new StringWriter();
error.printStackTrace(new PrintWriter(string));
dynamicTexts.add(string.toString());
}
}
}
} finally {
jspFactory.releasePageContext(pageContext);
}
jsonResponse.put("_dynamicTexts", dynamicTexts);
// Write the JSON response.