[opencms-dev] Again on JSP with template

José Checa Claudel jcheca at uco.es
Sun May 23 10:48:02 CEST 2004


Hi Domenico, I’ve been reading your posts and I think you are a bit
confused. I’ll try to explain you in a few words.

 

1º) You will have to do your template: these are two files (2), a definition
file within an XML and a .JSP file to define the squeletom of your page
(your real  template). In your /system/modules/<yourmodule>/template will
define this two files:

 

File1 – definition: 

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<xmltemplate>

 

   <stylesheet></stylesheet>

 

   <template>

      <element name="def01"/>

   </template>

 

   <elementdef name="def01">

      <class>com.opencms.flex.CmsJspTemplate</class>   

      <template>esqueletom.jsp</template>

   </elementdef>

    

</xmltemplate>

 

File2- esqueletom.jsp:

 

<%@ page session="false" %>

<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>

 

<html>

<title>Header File</title>

<body>

 

  <cms:include element="body" />   

 

</body>

</html>

 

That’s all; from now you could create a new .html file, select this
template, and all information you write in your editor, would be embebed
instead of <cms:include element="body" />. ¿ ok ? .... simple template
functions !!

 

But, what’s happend with new .JSP files, there are no posibilities to select
any template, so ...

 

When you create a .JSP file, you will have to do some steps to use the
template:

 

1º) you will have to create a new property for this new .jsp file, the name
of this property is ‘template’ and the value would be the name of the
esqueletom.jsp file with all path
(/system/modules/<yourmodule>/esqueletom.jsp). This way, we select the
template for .JSP !! don’t forget it !!

 

2º) in your esqueletom.jsp will have to make some changes, look:

 

<%@ page session="false" %>

<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>

 

<cms:template element="head">

   <html>

   <title>Header File</title>

   <body>

</cms:template>

 

<cms:include element="body" />   

 

<cms:template element="foot">

  </body>

  </html>

</cms:template>

 

... we use two new tag’s, one to define “head” area and other “foot” area.

 

3º) in your .JSP page, you will have to include the areas of this template
in your code, for instance:

 

<%@ page session="false" %>

<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>

<%@ page import="java.io.*" %>

 

<cms:include property="template" element="head" />

   La hora actual es <%= new java.util.Date() %><p>

<cms:include property="template" element="foot" />

 

 

That’s all. I hope this will be usefull, this time.

 

Jose Checa – jcheca at uco.es

Universidad de Córdoba - Spain

  _____  

De: opencms-dev-admin at opencms.org [mailto:opencms-dev-admin at opencms.org] En
nombre de Domenico De Seta
Enviado el: domingo, 23 de mayo de 2004 0:01
Para: Opencms-Dev
Asunto: [opencms-dev] Again on JSP with template

 

 

 

Hi Arian (is this your name?),

 

Thank you for the answer but I am not quite sure to understand how to use
it: could you please clarify where the piece of code you suggest must be
put? Which element must be substituted with specific data, I guess
"yourjsp.jsp" refers to my JSP page (correct?), but what about
<template><element name="jsp"/></template> ?

 

Regards

 

Domenico=20

 


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.687 / Virus Database: 448 - Release Date: 16/05/2004


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20040523/1fed9a86/attachment.htm>


More information about the opencms-dev mailing list