/**
* Build the model that to process the template against.
*
* The model includes the usual template root objects such as 'companyhome', 'userhome',
* 'person' and also includes the node specified on the servlet URL as 'space' and 'document'
*
* @param services ServiceRegistry
* @param req Http request - for accessing Session and url args
* @param templateRef NodeRef of the template itself
* @param nodeRef NodeRef of the space/document to process template against
*
* @return an object model ready for executing template against
*/
@SuppressWarnings("unchecked")
private Map
{
// build FreeMarker default model and merge
Map
// put the current NodeRef in as "space" and "document"
root.put("space", nodeRef);
root.put("document", nodeRef);
// add URL arguments as a map called 'args' to the root of the model
Map
Enumeration names = req.getParameterNames();
while (names.hasMoreElements())
{
String name = (String)names.nextElement();
try
{
args.put(name, new String(req.getParameter(name).getBytes(), "UTF-8"));
}
catch (UnsupportedEncodingException err) {}
}
root.put("args", args);
// Add the image resolver
root.put(TemplateService.KEY_IMAGE_RESOLVER, imageResolver);
// method to allow client urls to be generated
root.put("url", new URLHelper(req));
return root;
}
No comments:
Post a Comment