/**
* 3. Get RTFtemplate with Implementation
*/
String rtfTemplateImpl = getRTFTemplateImpl(request);
RTFTemplate rtfTemplate = (rtfTemplateImpl != null ? builder.
newRTFTemplate(rtfTemplateImpl) : builder.newRTFTemplate());
rtfTemplate.setGroupByPerPageBreak(getGroupByPerPageBreak(request));
/**
* 4. Put default format
*/
putDefaultFormat(request, rtfTemplate);
/**
* 5. Create a common inner context - not required but showing how common context values can be re-used
*/
IContext ctx = rtfTemplate.getTemplateEngine().newContext();
putGlobalContext(request, ctx);
/**
* 6. Set the template
*/
boolean isAlreadyCached = this.setTemplate(request, rtfTemplate, cacheWitkKey);
/**
* 8. Put Context
*/
putContext(request, rtfTemplate.getContext());
/*
* set the content type
*/
setContentType( request, response );
String fileName = getFileNameOfContentDisposition(request);
if (fileName != null) {
/*
* set the filename of content disposition
*/
setContentDisposition(response, fileName);
}
/**
* 10. Write to servlet Output
* result of Merge data with RTF model
*/
Writer writer = response.getWriter();
rtfTemplate.merge( writer);
if (cacheWitkKey != null && !isAlreadyCached) {
cachedTransformedDocumentMap.put(cacheWitkKey, rtfTemplate.getTransformedDocument());
}
}
catch (Exception e)