public void renderContentEnd(
      Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content)
      throws IOException {
    String expandedContentId = content.getContentId(context);
    String editMode = "Edit";
    String editRequest = content.getEditRequest(context);
    String enableEditName = content.getEnableEditName(context);
    String enableEditValue = (String) context.get(enableEditName);
    String urlString = "";
    if (editRequest != null && editRequest.toUpperCase().indexOf("IMAGE") > 0) {
      editMode += " Image";
    }

    if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) {
      HttpServletResponse response = (HttpServletResponse) context.get("response");
      HttpServletRequest request = (HttpServletRequest) context.get("request");
      if (request != null && response != null) {
        if (editRequest.indexOf("?") < 0) editRequest += "?";
        else editRequest += "&amp;";
        editRequest += "contentId=" + expandedContentId;
        ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
        urlString = rh.makeLink(request, response, editRequest, false, false, false);
      }

      Map<String, Object> parameters = FastMap.newInstance();
      parameters.put("urlString", urlString);
      parameters.put("editMode", editMode);
      parameters.put("editContainerStyle", content.getEditContainerStyle(context));
      parameters.put("editRequest", editRequest);
      parameters.put("enableEditValue", enableEditValue);
      executeMacro(writer, "renderContentEnd", parameters);
    }
  }
  public void renderContentBegin(
      Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content)
      throws IOException {
    String editRequest = content.getEditRequest(context);
    String enableEditName = content.getEnableEditName(context);
    String enableEditValue = (String) context.get(enableEditName);

    if (Debug.verboseOn()) Debug.logVerbose("directEditRequest:" + editRequest, module);

    Map<String, Object> parameters = FastMap.newInstance();
    parameters.put("editRequest", editRequest);
    parameters.put("enableEditValue", enableEditValue == null ? "" : enableEditValue);
    parameters.put("editContainerStyle", content.getEditContainerStyle(context));
    executeMacro(writer, "renderContentBegin", parameters);
  }
  public void renderContentBody(
      Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content)
      throws IOException {
    Locale locale = UtilMisc.ensureLocale(context.get("locale"));
    // Boolean nullThruDatesOnly = Boolean.valueOf(false);
    String mimeTypeId = "text/html";
    String expandedContentId = content.getContentId(context);
    String expandedDataResourceId = content.getDataResourceId(context);
    String renderedContent = null;
    LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher");
    Delegator delegator = (Delegator) context.get("delegator");

    // make a new map for content rendering; so our current map does not get clobbered
    Map<String, Object> contentContext = FastMap.newInstance();
    contentContext.putAll(context);
    String dataResourceId = (String) contentContext.get("dataResourceId");
    if (Debug.verboseOn()) Debug.logVerbose("expandedContentId:" + expandedContentId, module);

    try {
      if (UtilValidate.isNotEmpty(dataResourceId)) {
        if (WidgetDataResourceWorker.dataresourceWorker != null) {
          renderedContent =
              WidgetDataResourceWorker.dataresourceWorker.renderDataResourceAsTextExt(
                  delegator, dataResourceId, contentContext, locale, mimeTypeId, false);
        } else {
          Debug.logError(
              "Not rendering content, WidgetDataResourceWorker.dataresourceWorker not found.",
              module);
        }
      } else if (UtilValidate.isNotEmpty(expandedContentId)) {
        if (WidgetContentWorker.contentWorker != null) {
          renderedContent =
              WidgetContentWorker.contentWorker.renderContentAsTextExt(
                  dispatcher,
                  delegator,
                  expandedContentId,
                  contentContext,
                  locale,
                  mimeTypeId,
                  true);
        } else {
          Debug.logError(
              "Not rendering content, WidgetContentWorker.contentWorker not found.", module);
        }
      } else if (UtilValidate.isNotEmpty(expandedDataResourceId)) {
        if (WidgetDataResourceWorker.dataresourceWorker != null) {
          renderedContent =
              WidgetDataResourceWorker.dataresourceWorker.renderDataResourceAsTextExt(
                  delegator, expandedDataResourceId, contentContext, locale, mimeTypeId, false);
        } else {
          Debug.logError(
              "Not rendering content, WidgetDataResourceWorker.dataresourceWorker not found.",
              module);
        }
      }
      if (UtilValidate.isEmpty(renderedContent)) {
        String editRequest = content.getEditRequest(context);
        if (UtilValidate.isNotEmpty(editRequest)) {
          if (WidgetContentWorker.contentWorker != null) {
            WidgetContentWorker.contentWorker.renderContentAsTextExt(
                dispatcher,
                delegator,
                "NOCONTENTFOUND",
                writer,
                contentContext,
                locale,
                mimeTypeId,
                true);
          } else {
            Debug.logError(
                "Not rendering content, WidgetContentWorker.contentWorker not found.", module);
          }
        }
      } else {
        if (content.xmlEscape()) {
          renderedContent = UtilFormatOut.encodeXmlValue(renderedContent);
        }

        writer.append(renderedContent);
      }

    } catch (GeneralException e) {
      String errMsg =
          "Error rendering included content with id [" + expandedContentId + "] : " + e.toString();
      Debug.logError(e, errMsg, module);
      // throw new RuntimeException(errMsg);
    } catch (IOException e2) {
      String errMsg =
          "Error rendering included content with id [" + expandedContentId + "] : " + e2.toString();
      Debug.logError(e2, errMsg, module);
      // throw new RuntimeException(errMsg);
    }
  }