[opencms-dev] RE: RE: Need help with templates, please

Jonathan Woods jonathan.woods at scintillance.com
Wed Apr 18 16:12:04 CEST 2007


Christoph -

Thanks for your feedback - appreciated.  I'm unfortunately often prevented
from providing the full answer to these questions, as you have, by the fact
that I long ago gave up on the taglib and rolled my own XML
searching/loading mechanism - which has its good and bad points!

One further thought on this one: I've found it valuable to pass state around
as an attribute of CmsJspActionElement's CmsRequestContext, and to do so not
by setting loads of String attribute values but by having my own class -
RequestState - which acts as a value object.  I share this among JSPs which
invoke/include one another, and fully modelling shared state in this way
makes code a lot safer than String-based programming.

Jon

-----Original Message-----
From: Christoph Schönfeld [mailto:cschoenfeld at sylphen.com] 
Sent: 18 April 2007 12:41
To: The OpenCms mailing list
Subject: Re: [opencms-dev] RE: RE: Need help with templates, please

Jonathan, once again you have given the most relevant hint about a problem.
Thank you very much for your answers on this list.

I had the same/similar problem. I needed to include rendered xmlcontent
files from a central portal template.

Here is how I made sure that the JSP knows which resource it's supposed to
render.

My central template receives the path of the xmlcontent file to include as a
request parameter and uses <cms:include page="article.jsp"/> to include the
file. article.jsp is also set as the template-elements property of the
xmlcontent files. The path of the file is passed to article.jsp via the HTTP
session.

My code in article.jsp determines the path from the session and then sets it
as a page context variable which is referred to by the contentload tag. If
no path is found in the session it is assumed that the xmlcontent file is
called directly within the Explorer or by invocation of its URL. In this
case the page context variable is set to the value of the OpenCms request
context URI (which has the same value as ${opencms.uri}).

Code snippet from article.jsp:
<%
String path = // something like session.getAttribute("...");
if (null == path) {               
    CmsJspActionElement jsp =
      new CmsJspActionElement(pageContext, request, response);
    pageContext.setAttribute("uri", jsp.getRequestContext().getUri());
} else {
    pageContext.setAttribute("uri", path); } %> <cms:contentload
collector="singleFile" param="${pageContext.uri}"
    editable="true">
</cms:contentload>


Best regards,
Christoph

_______________________________________________
This mail is sent to you from the opencms-dev mailing list To change your
list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev






More information about the opencms-dev mailing list