[opencms-dev]Publishing jsp content that is part of an XML te mplate JSP
Rod Thorburn
rod.thorburn at pavtech.co.nz
Thu Sep 19 02:33:19 CEST 2002
Thanks Mark - that worked fine. However, I've only managed to get the
desired output in "off-line" mode. In other words, it would appear that the
jsp element is not being published, or is inaccessable to the other page
elements.
Using Alexander Kandzior's example from [opencms-dev]flex: JSP and
templates? August 30, I inserted a reference to a jsp element in a page
template which resides in /content/templates/, as below:
---------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<XMLTEMPLATE>
<ELEMENTDEF name="header">
<CLASS>com.opencms.template.CmsXmlTemplate</CLASS>
<TEMPLATE>/content/elements/static_header</TEMPLATE>
</ELEMENTDEF>
<ELEMENTDEF name="frametemplate">
<CLASS>com.opencms.template.CmsXmlTemplate</CLASS>
<TEMPLATE>/content/frametemplates/main_frame_template</TEMPLATE>
</ELEMENTDEF>
<ELEMENTDEF name="bodycontent">
<CLASS>com.opencms.template.CmsXmlTemplate</CLASS>
<TEMPLATE>/content/elements/body_with_right_channel</TEMPLATE>
</ELEMENTDEF>
<ELEMENTDEF name="contenttemplate">
<CLASS>com.opencms.template.CmsXmlTemplate</CLASS>
<TEMPLATE>/content/contenttemplates/Article_Content_Template</TEMPLATE>
</ELEMENTDEF>
<elementdef name="document_body">
<CLASS>com.opencms.flex.CmsJspTemplate</CLASS>
<TEMPLATE>/content/elements/newsHeadlines.jsp</TEMPLATE>
</elementdef>
<TEMPLATE>
<ELEMENT name="frametemplate"/>
</TEMPLATE>
</XMLTEMPLATE>
----------------------------------------------------------------------------
-
The jsp in question (newsHeadlines.jsp) resides in /content/elements/ .It's
export property=false, cache=always and stream=true.
However, when I view the page that this template produces in "online" mode,
all page elements are rendered except the "document_body" element, for which
"[document_body] ??? " is displayed.
The above is executed in opencms5_beta. Combinations of export=true/false
seem to make no difference, though I suspect that the problem rests there
somehow.
Any advice would be greatly appreciated.
Regards, Rod
-----Original Message-----
From: mfoley5 at csc.com.au [mailto:mfoley5 at csc.com.au]
Sent: Wednesday, September 18, 2002 2:33 PM
To: opencms-dev at www.opencms.org
Subject: Re: [opencms-dev] extracting Property attributes from within a
JSP
Hi Rod,
You could try something like:
com.opencms.flex.cache.CmsFlexRequest req
= (com.opencms.flex.cache.CmsFlexRequest)request;
com.opencms.file.CmsObject cms = req.getCmsObject();
String docRole = cms.readProperty(cRes.getAbsolutePath(),"Role");
Here we have created another property called "Role" which contains string
info. You can equally well use this for default properties, such as
"Title" and "Description".
Regards,
Mark
Mark Foley
__________________________________________________
CSC
212 Northbourne Ave, Braddon, ACT 2612
Ph: +61-2-62468487 Email: mfoley5 at csc.com.au
----------------------------------------------------------------------------
------------
This email, including any attachments, is intended only for use by the
addressee(s) and may contain confidential and/or personal information and
may also be the subject of legal privilege. Any personal information
contained in this email is not to be used or disclosed for any purpose
other than the purpose for which you have received it. If you are not the
intended recipient, you must not disclose or use the information contained
in it. In this case, please let me know by return email, delete the message
permanently from your system and destroy any copies.
----------------------------------------------------------------------------
------------
"Rod Thorburn"
<rod.thorburn at pavtech. To:
<opencms-dev at opencms.com>
co.nz> cc:
Sent by: Subject: [opencms-dev]
extracting Property attributes from within a JSP
owner-opencms-dev at www.
opencms.org
18/09/2002 09:53 AM
Please respond to
opencms-dev
I am exploring the jsp functionality in opencms5_beta to build a dynamic
directory listing (based on the flex-examples that came with the
distribution). The following code snippet returns the Description, Title
and NavText elements for each .html file in the directory /news/articles/
// Link substitutor to make sure static export works
com.opencms.util.LinkSubstitution subst = new
com.opencms.util.LinkSubstitution();
// Collect the objects required to access the OpenCms VFS from the
request
com.opencms.flex.cache.CmsFlexRequest req
= (com.opencms.flex.cache.CmsFlexRequest)request;
com.opencms.file.CmsObject cms = req.getCmsObject();
com.opencms.file.CmsFile file = req.getCmsFile();
// Get the folder name
String foldername = "/news/articles/";
// Get a list of all pages / subfolders in the folder (sorted by
NavPos property)
java.util.ArrayList list =
CmsJspNavElement.getNavigationForFolder(cms, foldername);
java.util.Iterator i = list.iterator();
while (i.hasNext())
{
CmsJspNavElement ne = (CmsJspNavElement)i.next();
%><p>
<%=ne.getDescription() != null ? ne.getDescription() : ""
%><br>
<%=ne.getTitle() != null ? ne.getTitle() : "" %><br>
<a href="<%=subst.getLinkSubstitution(cms, ne.getResourceName
())%>"><%=ne.getNavText() != null ? ne.getNavText() : "" %
></a>
</p><%
}
What I also want to do is extract or use other Property values for a given
.html file, that are not defined by CmsJspNavElement.java . For example , I
may have created a Property called "Date", or I might want to select only
certain .html files by a value in the "Key Words" Property.
The temtation is to call the method getProperty() , but this method is not
defined in the CmsJspNavElement class (as far as I can determine it is only
available in CmsJspTagUser.java) .
Does anyone know of a way of accessing additional file Properties in the
above context without writing additional code in the appropriate classes?
Rod
NOTICE: The information contained in this electronic mail message and any
attachments is confidential to Pavilion Technologies, Inc. or one of its
subsidiaries and may contain proprietary information or be legally
privileged. This message and any attachments are intended only for the
personal and confidential use of the designated recipient(s). If you are not
the intended recipient or an agent responsible for delivering it to the
intended recipient, you are hereby notified that you have received this
message in error, and that any review, dissemination, distribution or
copying of this message and any attachments is unauthorised and strictly
prohibited. If you have received this message in error, please notify me
immediately by telephone and electronic mail, and delete this message, any
attachments, and all copies thereof. Thank you very much.
More information about the opencms-dev
mailing list