6

We're busy upgrading to Web 8.5, and I'm having some problems with JSP Dynamic Component Presentations. These are correctly deployed to disk, and the ComponentPresentationFactory is able to locate my test DCP. However, when I invoke the ComponentPresenationAssembler like this:

ComponentPresentationAssembler componentPresentationAssembler 
                                 = new ComponentPresentationAssembler(127); 
out.write(componentPresentationAssembler.getContent(513988, 243136));

then I get the same output as if I invoke the ComponentPresentationFactory like this:

com.tridion.dcp.ComponentPresentationFactory cpf 
                                = new com.tridion.dcp.ComponentPresentationFactory(127);
com.tridion.dcp.ComponentPresentation cp = cpf.getComponentPresentation(513988, 243136);
out.write(cp.getContent());

In other words, what I see is the raw JSP code, and not the rendered output that I expected.

When I call cp.isDynamic(), the result is false, although I don't know whether that is significant. In the Broker database I can see that the TEMPLATE_OUTPUT_FORMAT of the Component Template is, as expected, JSP Scripting.

What can cause this? Where should I be looking to get some insight into this problem?

1 Answer 1

3

The ComponentPresentationAssembler needs access to your page context to work, so the constructor overload that accepts just the publication id won't work. You need to instantiate a JSPPage with the pageContext and pass that in.

com.tridion.web.jsp.JSPPage dcdPage 
                         = new com.tridion.web.jsp.JSPPage(pageContext, "tcm:127-507637-64");
ComponentPresentationAssembler componentPresentationAssembler 
                             = new ComponentPresentationAssembler(dcdPage);

(I'd changed the constructor in my test case while solving a different problem.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.