}
public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) {
String name = this.getName(context);
String location = this.getLocation(context);
ModelMenu modelMenu = null;
try {
modelMenu = MenuFactory.getMenuFromLocation(this.getLocation(context), this.getName(context), this.modelScreen.getDelegator(context), this.modelScreen.getDispatcher(context));
} catch (IOException e) {
String errMsg = "Error rendering included menu named [" + name + "] at location [" + location + "]: " + e.toString();
Debug.logError(e, errMsg, module);
throw new RuntimeException(errMsg);
} catch (SAXException e) {
String errMsg = "Error rendering included menu named [" + name + "] at location [" + location + "]: " + e.toString();
Debug.logError(e, errMsg, module);
throw new RuntimeException(errMsg);
} catch (ParserConfigurationException e) {
String errMsg = "Error rendering included menu named [" + name + "] at location [" + location + "]: " + e.toString();
Debug.logError(e, errMsg, module);
throw new RuntimeException(errMsg);
}
// try finding the menuStringRenderer by name in the context in case one was prepared and put there
MenuStringRenderer menuStringRenderer = (MenuStringRenderer) context.get("menuStringRenderer");
// if there was no menuStringRenderer put in place, now try finding the request/response in the context and creating a new one
if (menuStringRenderer == null) {
HttpServletRequest request = (HttpServletRequest) context.get("request");
HttpServletResponse response = (HttpServletResponse) context.get("response");
if (request != null && response != null) {
menuStringRenderer = new HtmlMenuRenderer(request, response);
}
}
// still null, throw an error
if (menuStringRenderer == null) {
throw new IllegalArgumentException("Could not find a menuStringRenderer in the context, and could not find HTTP request/response objects need to create one.");
}
StringBuffer renderBuffer = new StringBuffer();
modelMenu.renderMenuString(renderBuffer, context, menuStringRenderer);
try {
writer.write(renderBuffer.toString());
} catch (IOException e) {
String errMsg = "Error rendering included menu named [" + name + "] at location [" + location + "]: " + e.toString();
Debug.logError(e, errMsg, module);