public static Map<String,Object> renderContentAsText(DispatchContext dctx,Map<String,? extends Object> context){
  Map<String,Object> results=FastMap.newInstance();
  LocalDispatcher dispatcher=dctx.getDispatcher();
  Delegator delegator=dctx.getDelegator();
  Writer out=(Writer)context.get("outWriter");
  Map<String,Object> templateContext=UtilGenerics.checkMap(context.get("templateContext"));
  String contentId=(String)context.get("contentId");
  if (templateContext != null && UtilValidate.isEmpty(contentId)) {
    contentId=(String)templateContext.get("contentId");
  }
  String mimeTypeId=(String)context.get("mimeTypeId");
  if (templateContext != null && UtilValidate.isEmpty(mimeTypeId)) {
    mimeTypeId=(String)templateContext.get("mimeTypeId");
  }
  Locale locale=(Locale)context.get("locale");
  if (templateContext != null && locale == null) {
    locale=(Locale)templateContext.get("locale");
  }
  if (templateContext == null) {
    templateContext=FastMap.newInstance();
  }
  Writer outWriter=new StringWriter();
  GenericValue view=(GenericValue)context.get("subContentDataResourceView");
  if (view != null && view.containsKey("contentId")) {
    contentId=view.getString("contentId");
  }
  try {
    ContentWorker.renderContentAsText(dispatcher,delegator,contentId,outWriter,templateContext,locale,mimeTypeId,null,null,true);
    if (out != null)     out.write(outWriter.toString());
    results.put("textData",outWriter.toString());
  }
 catch (  GeneralException e) {
    Debug.logError(e,"Error rendering sub-content text",module);
    return ServiceUtil.returnError(e.toString());
  }
catch (  IOException e) {
    Debug.logError(e,"Error rendering sub-content text",module);
    return ServiceUtil.returnError(e.toString());
  }
  return results;
}

public static Map < String , Object > renderContentAsText ( DispatchContext dctx , Map < String , ? extends Object > context ) { Map < String , Object > results = FastMap . newInstance ( ) ; LocalDispatcher dispatcher = dctx . getDispatcher ( ) ; Delegator delegator = dctx . getDelegator ( ) ; Writer out = ( Writer ) context . get ( "outWriter" ) ; Map < String , Object > templateContext = UtilGenerics . checkMap ( context . get ( "templateContext" ) ) ; String contentId = ( String ) context . get ( "contentId" ) ; if ( templateContext != null && UtilValidate . isEmpty ( contentId ) ) { contentId = ( String ) templateContext . get ( "contentId" ) ; } String mimeTypeId = ( String ) context . get ( "mimeTypeId" ) ; if ( templateContext != null && UtilValidate . isEmpty ( mimeTypeId ) ) { mimeTypeId = ( String ) templateContext . get ( "mimeTypeId" ) ; } Locale locale = ( Locale ) context . get ( "locale" ) ; if ( templateContext != null && locale == null ) { locale = ( Locale ) templateContext . get ( "locale" ) ; } if ( templateContext == null ) { templateContext = FastMap . newInstance ( ) ; } Writer outWriter = new StringWriter ( ) ; GenericValue view = ( GenericValue ) context . get ( "subContentDataResourceView" ) ; if ( view != null && view . containsKey ( "contentId" ) ) { contentId = view . getString ( "contentId" ) ; } try { ContentWorker . renderContentAsText ( dispatcher , delegator , contentId , outWriter , templateContext , locale , mimeTypeId , null , null , true ) ; if ( out != null ) out . write ( outWriter . toString ( ) ) ; results . put ( "textData" , outWriter . toString ( ) ) ; } catch ( GeneralException e ) { Debug . logError ( e , "Error rendering sub-content text" , module ) ; return ServiceUtil . returnError ( e . toString ( ) ) ; } catch ( IOException e ) { Debug . logError ( e , "Error rendering sub-content text" , module ) ; return ServiceUtil . returnError ( e . toString ( ) ) ; } return results ; }
get and render subcontent associated with template id and mapkey . if subcontentid is supplied , that content will be rendered without searching for other matching content .
