Running Component Presentation code and adding the result to a Web page
Use the ComponentPresentationAssembler class to execute any code in the Component Presentation, then add the result to the Web page.
The ComponentPresentationAssembler class assembles Dynamic Component Presentations on a Page. You can use the Component Presentation Assembler to dynamically add content of Dynamic Component Presentations to the content of your Page. The Component Presentation Assembler invokes handlers for JSP and XML/XSLT content.
This ComponentPresentationAssembler class has a getContent or GetContent method that retrieves the contents of the Component Presentation and executes any TCDL code in it (ASP.NET and JSP code remains 'as is'). The Component Presentation Assembler can also read the metadata of the Dynamic Component Presentation.
Note that if you enabled caching for Component Presentations, the Component Presentation content is cached, but the rendered code is not.
The following example illustrates how to use the Component Presentation Assembler to assemble ASP.NET content from an ASP.NET Page:
<%@ Import Namespace=" Tridion.ContentDelivery.Web.DynamicContent"%>
<%
ComponentPresentationAssembler componentPresentationAssembler = new ComponentPresentationAssembler("tcm:28-476-64", Page);
Response.Write(componentPresentationAssembler.GetContent("tcm:28-780","tcm:28-821-32"));
%>
...
<%
componentPresentationAssembler.Dispose();
%>
And here is a JSP example assembling JSP content:
<%@ page import="com.tridion.web.jsp.JSPPage, com.tridion.web.jsp.ComponentPresentationAssembler" %>
<%
JSPPage dcdPage = new JSPPage(pageContext, "tcm:28-834-64");
ComponentPresentationAssembler cpAssembler = new ComponentPresentationAssembler(dcdPage);
out.println(cpAssembler.getContent("tcm:28-780","tcm:28-821-32"));
%>
And here is a JSP example assembling TCDL content:
<%
ComponentPresentationAssembler cpAssembler = new ComponentPresentationAssembler(2);
out.println(cpAssembler.getContent("tcm:28-780","tcm:28-821-32", new HashMap<String, String>()));
%>