if (UtilValidate.isEmpty(attachmentName)) {
attachmentName = "Details.pdf";
}
StringWriter bodyWriter = new StringWriter();
MapStack screenContext = MapStack.create();
screenContext.put("locale", locale);
ScreenRenderer screens = new ScreenRenderer(bodyWriter, screenContext, htmlScreenRenderer);
screens.populateContextForService(dctx, bodyParameters);
screenContext.putAll(bodyParameters);
if (bodyScreenUri != null) {
try {
screens.render(bodyScreenUri);
} catch (GeneralException e) {
String errMsg = "Error rendering screen for email: " + e.toString();
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
} catch (IOException e) {
String errMsg = "Error rendering screen for email: " + e.toString();
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
} catch (SAXException e) {
String errMsg = "Error rendering screen for email: " + e.toString();
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
} catch (ParserConfigurationException e) {
String errMsg = "Error rendering screen for email: " + e.toString();
Debug.logError(e, errMsg, module);
return ServiceUtil.returnError(errMsg);
}
}
boolean isMultiPart = false;
// check if attachement screen location passed in
if (UtilValidate.isNotEmpty(xslfoAttachScreenLocation)) {
isMultiPart = true;
// start processing fo pdf attachment
try {
Writer writer = new StringWriter();
MapStack screenContextAtt = MapStack.create();
// substitute the freemarker variables...
ScreenRenderer screensAtt = new ScreenRenderer(writer, screenContext, htmlScreenRenderer);
screensAtt.populateContextForService(dctx, bodyParameters);
screenContextAtt.putAll(bodyParameters);
screensAtt.render(xslfoAttachScreenLocation);
/*
try { // save generated fo file for debugging
String buf = writer.toString();