[opencms-dev] Trying to include a file and have template applied

Polizzi, Jim Jim.Polizzi at bankofamerica.com
Mon Nov 10 20:00:02 CET 2003


Let me restate the problem - with much more definition.
 
I'm writing a jsp page and trying to include a file (.html - or whatever) that has a template defined for it (thus allow the user to create a body - but I define the formatting, etc.).  I call "cms.include("myPage.html");".  The results that I get are the BODY of the included file but not the Template stuff (my formatting stuff - tables, etc.)
 
I've created a very simple example (below) that shows exactly what I mean.
 
 
Let's say that I have the following template: (myTemplate.jsp)

<%@ page session="false" 
    import="com.opencms.flex.jsp.*"
    import="com.opencms.flex.util.CmsMessages" 
    import="com.opencms.file.*" 
    import="java.lang.*" 
    import="java.util.*" 
%>
<%
 
// initialise Cms Action Element
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
 
out.println("<h2>This is from the template!!!</h2>");


cms.include(null, "body");

Also - let's say that you have a page (myPage.html) that uses myTemplate.jsp - with the following body content:

<h3>This is the body content</h3>

Good - now - let's say that we have the following JSP file - (myJSP.jsp):

<%@ page session="false" 
    import="com.opencms.flex.jsp.*"
    import="com.opencms.flex.util.CmsMessages" 
    import="com.opencms.file.*" 
    import="java.lang.*" 
    import="java.util.*" 
%>
<%
// initialise Cms Action Element
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
%>
 
<html>
<head>
<title>Test Page</title>
</head>
<body leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
<h1>This is myJSP.jsp</h1>
 
<%
out.println("<h1>including myPage.html.</h1>");
cms.include("myPage.html");
%>
 
</body>
</html>

Ok - that's all of the files in this example.  When I open myJSP.jsp, the results are:


<html>
<head>
<title>Test Page</title>
</head>
<body leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">

<h1>This is myJSP.jsp</h1>
 

<h1>including myPage.html.</h1>


<h3>This is the body content</h3>

</body>
</html>
 

NOTE:  I DON'T get the Template output -->    <h2>This is from the template!!!</h2>
I don't understand why not - or how I CAN get it.
 
Any help in this would be appreciated.
 
Jim Polizzi

-----Original Message-----
From: Claus Priisholm [mailto:cpr at codedroids.com]
Sent: Monday, November 10, 2003 5:57 AM
To: opencms-dev at opencms.org
Subject: Re: [opencms-dev] Trying to include a file and have template applied


I'm not sure what kind of include you're using (and what it is that you need the template to do), but I had a problem where an include of a header 'page' would mess up the remaining includes on the page. In order for that to work I would either have to use a Java URLConnection to actually fetch the result or apply this workaround provided by Brett Beaumont: 

http://mail.opencms.org/pipermail/opencms-dev/2003q3/007010.html 

On fredag, nov 7, 2003, at 17:00 Europe/Copenhagen, Polizzi, Jim wrote: 


I am trying to include a file (.html) that has a template defined for it.  The problem is that the file is included - but the template is not applied... I'm ONLY getting the body content - without the template 
Can anyone shed some light on this? 


-- 
Claus Priisholm 
+45 48 22 46 46 
cpr (you-know-what) interlet.dk - cpr (you-know-what) codedroids.com 
http://www.interlet.dk - http://www.codedroids.com 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20031110/8ba49eb9/attachment.htm>


More information about the opencms-dev mailing list