[opencms-dev] Re ndering an element with a certain formatter programmatically

Tobias Herrmann t.herrmann at alkacon.com
Wed Nov 14 16:19:16 CET 2012


Hi Roel,

take a look at org.opencms.jsp.CmsJspTagContainer line 970 and following.
Get an instance of CmsJspStandardContextBean like this:
CmsJspStandardContextBean  standardContext = CmsJspStandardContextBean.getInstance(req);
Also create an CmsContainerElementBean instance for the XMLContent resource you want to render and follow the example in the CmsJspTagContainer class.

Greetings, Tobias

--

Alkacon Software GmbH - The OpenCms Experts

http://www.alkacon.com
http://www.opencms.org

Am 14.11.2012 15:43, schrieb Fr3z:
> I have the UUID of an element (fe a news item), so I can acces its entire
> xmlcontent.
>
> Now, is there a way to programmatically render this element in a jsp with a
> formatter of my choice instead of copying the code of the formatter in this
> jsp?
>
> I was trying via:
>
> <%
> 	
> 	CmsUUID elementId = new CmsUUID("368253f9-280e-11e2-87b4-6f30f3c96804");
> //hardcoded UUID for testing purposes
> 	
> 	CmsResource formatter =
> cms.readResource("/system/modules/be.redtree.crelan.intranet.news/formatters/detail.jsp");
> 	CmsUUID formatterId = formatter.getStructureId();
>
> 	CmsContainerElementBean containerelement = new
> CmsContainerElementBean(elementId, formatterId, null, false);
> %>
>
> But I can't seem to get any further.
>
> Actually I'm looking for some kind of method that does this:
> render(XMLcontent,formatter) and then displays it correctly.
>
> Anyone has any advice, help, manual about this?
>
> Kind regards,
>
> Roel Frison




More information about the opencms-dev mailing list