[opencms-dev] Bug in CmsJspActionElement.include ?

Brett Beaumont brett.beaumont at sytec.co.nz
Fri Sep 5 08:40:02 CEST 2003


I had a similar problem but I was only including the default body.  

It doesn't seem like OpenCMS likes to include bodies from multiple pages in
one template.  I added to following code to the top of one of my JSPs to
resolve the problem:

<%@ page import = "com.opencms.template.*" %>
<%@ page import = "com.opencms.flex.jsp.CmsJspActionElement " %>

<%! public String include(CmsJspActionElement cms, String uri) throws
com.opencms.core.CmsException {
      CmsXmlTemplate t = new CmsXmlTemplate();
      CmsXmlTemplateFile tf = new CmsXmlTemplateFile(cms.getCmsObject(),
"/system/bodies" + uri);
      return tf.getProcessedTemplateContent(t, null, null);
    }
%>

and I would then call:

<%= include(cms, uri) %>

instead of cms.include.
To get your "abstract" body, I think you will need to modify the last line
in my include method to read:

return tf.getProcessedTemplateContent(t, null, "abstract");

Let me know how you get on.

Regards,

Brett Beaumont




-----Original Message-----
From: A. Schirmacher [mailto:nn4l at yahoo.de]
Sent: Friday, 5 September 2003 5:44 p.m.
To: opencms-dev at opencms.org
Subject: [opencms-dev] Bug in CmsJspActionElement.include ?


I have set up a template with two main content areas,
the second one holds a brief "abstract" text.

I want to display an overview page, which has a list
of all "abstract" text, plus a link to the full
article.

The overview page is currently in the same directory
as the articles and has an abstract too. Which is of
course pointless, but I get strange effects here and I
believe this is a bug.

Here's the code for the overview page (jsptemplate).
The getResource string is always correct (it is the
uri for the articles), but the abstract of the
overview page is displayed only if it is first in the
navigation. In all other cases the abstract of the
previous article is displayed instead. 

This should not be the case. I think
cms.include(ne.getResourceName(), ..) should always
include the thing defined by getResourceName, and it
should never return a previous object.


    com.opencms.flex.jsp.CmsJspActionElement cms = new
CmsJspActionElement(pageContext, request, response);
	 
    // List of all pages / subfolders (sorted by
NavPos property)

    java.util.ArrayList list =
cms.getNavigation().getNavigationForFolder();	
    java.util.Iterator i = list.iterator();

    while (i.hasNext()) {
    	CmsJspNavElement ne = (CmsJspNavElement)i.next();
        out.println("getResourceName: " +
ne.getResourceName() + "<br>");
	cms.include(ne.getResourceName(), "abstract");
        out.println("<p>");
    }	


__________________________________________________________________

Gesendet von Yahoo! Mail - http://mail.yahoo.de
Logos und Klingeltöne fürs Handy bei http://sms.yahoo.de
_______________________________________________
This mail is send to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://mail.opencms.org/mailman/listinfo/opencms-dev



More information about the opencms-dev mailing list