protected Object createViewContext(JPublishContext context, String path) throws ViewRenderException {
HttpServletRequest request = context.getRequest();
HttpServletResponse response = context.getResponse();
BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
WrappingTemplateModel.setDefaultObjectWrapper(wrapper);
Map contextMap = new HashMap();
SimpleHash root = new SimpleHash(wrapper);
try {
Object[] keys = context.getKeys();
for (int i = 0; i < keys.length; i++) {
String key = (String) keys[i];
Object value = context.get(key);
if (value != null) {
contextMap.put(key, value);
//no longer wrapping; let FM do it if needed, more efficient
//root.put(key, wrapper.wrap(value));
root.put(key, value);
}
}
root.put("context", wrapper.wrap(contextMap));
root.put("cachedInclude", new JpCacheIncludeTransform()); // only adding this in for JP!
//root.put("jpublishContext", wrapper.wrap(context));
FreeMarkerViewHandler.prepOfbizRoot(root, request, response);
} catch (Exception e) {
throw new ViewRenderException(e);