[opencms-dev] JSP Development with IDEs like Netbeans

Mike Bachrynowski mikeb at tableau.co.uk
Thu Nov 25 13:21:48 CET 2004


I use Eclipse to contain a shadow copy of the interesting parts of the
VFS.  I use Ant to maintain version control.  If the config properties
files need to be changed I can automatically Tomcat deploy into the
OpenCms web app.  I automatically create "CmsShell importFile"
statements for the files that are changed and then run CmsShell as an
Ant task.  I avoid the OpenCms editor ... IMO it is best used just by
copy writers loading the web site content through fill in the blanks
edit forms.  They want a simple fast data entry system....and a few
extra buttons to validate, review and deploy.  

I use and IDE because of the volume of related tricky changes to turn an
"evaluation" project into a series of "operational" projects for a
number of clients.  I tend to minimise the "OpenCms" specific elements
that need to be developed generating automatically those that I can.
OpenCms is excellent in the batch interface it provides.  Below is the
approach I am currently using.  I would welcome comments on how this
approach could be improved.

==============
==============
 
I have created around 20 generic master xmlcontent schema / templates to
support Docbook.  These have to be customised (many more variants are
generated) for different clients, web apps and servers.  Without
automation I found this far too manually intensive and error prone.
Further I use a Java generator task to create the beans to simplify the
JSP.  These create classes, interfaces and factory methods in addition
to to the usual getter, setter and validate methods. (I had a play with
xdoclet but felt this was overengineered for my needs).   A starting
point of 20 template each with around 20 fields are too many
combinations to maintain manually.   For JSP I have extended the
CmsJspActionElement to provide me "simplified" access to the xmlcontent
related fields I need.  My JspHandler extends CmsJspActionElement.
Below is my "simplified" JSP.  I attempted similar with the cms
xmlcontent taglibs but they currently do not give me access to the
variables in the way that works for me (I do know the CVS Head has
improved tags).

My single generic JSP display page is as follows:
=======================================================
<%@page buffer="none" session="false"
import="com.tableau.opencms.xmlcontent.*" 
%><%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" 
%><%@ include file="elements/content-init.jsp" %> <HTML>
<HEAD>
  <TITLE> Display:  <%= mypath %> </TITLE>
</HEAD>
<BODY>

<h1> Display: <%= mypath %> </h1>
<%@ include file="elements/docbook-chapter.jsp" %>
<%@ include file="elements/docbook-mediaobject.jsp" %>

</BODY>
</HTML>
============================================================


"elements/content-init.jsp" is as follows.
===============================================================
<%
// Process CMS content
JspHandler cms              = new JspHandler(pageContext, request,
response);
String     mycontent        = cms.getXmlContentEscaped();
String     mydirectory      = cms.getContextDirectory();
String     mypath           = cms.getContextPath();
String     myfilename       = cms.getContextFilename();
String     mynamespace      = cms.getSchemaNamespace();
String     myschemafilename = cms.getSchemaFilename();
String     myjspfilename    = request.getRequestURI();
String     myfullname       =
cms.getRequestContext().currentUser().getFullName();
boolean    schemaFound      = false;
%> 
=================================================================


"elements/docbook-chapter.jsp" is as follows.
===================================================================
<% if ( myschemafilename.startsWith( "docbook-chapter-20" ) ) {
    schemaFound = true;
    DocbookChapter mydoc = DocbookChapterFactory.createDocbookChapter( 
       request, cms.getContextXmlDocument(), cms.getContextLocale(),
true );
%> <h3> XML Elements for "docbook-chapter" schema </h3>
<%@ include file="table-head.jsp"      %>
<%@ include file="table-chapter.jsp"   %>
<%@ include file="table-reference.jsp" %>
<%@ include file="table-tail.jsp"      %> <% } %>  
=======================================================

"table-chapter.jsp" is boring XHTML as follows.
=======================================================
<tr><td> ChapterTitle:    </td><td> <%= mydoc.getChapterTitle()    %>
</td><td> <%= mydoc.getChapterTitleMessages()    %> </td></tr>
<tr><td> ChapterSummary:  </td><td> <%= mydoc.getChapterSummary()  %>
</td><td> <%= mydoc.getChapterSummaryMessages()  %> </td></tr>
<tr><td> ChapterKeywords: </td><td> <%= mydoc.getChapterKeywords() %>
</td><td> <%= mydoc.getChapterKeywordsMessages() %> </td></tr>
<tr><td> ChapterText:     </td><td> <%= mydoc.getChapterText()     %>
</td><td> <%= mydoc.getChapterTextMessages()     %> </td></tr>
<tr><td colspan="3"><hr/></td></tr>


Extract from the output is as follows.
========================================================
Name:             Value:              Validation: 
ChapterTitle:     Page Title           OK  
ChapterSummary:   This is the summary. OK  
ChapterKeywords:  keya, keyb, keyc     OK  
ChapterText:                           Zero length  
.....
Reference 
Context Directory: /sites/default/tableau-test/test2/  
Context Path:      /sites/default/tableau-test/test2/docbook20a.html  
Context Filename:  docbook20a.html  
Schema Namespace:
opencms://system/schemas/opencms/docbook-chapter-2004-11-04a.xsd  
Schema Filename:   docbook-chapter-2004-11-04a.xsd  
JSP Filename:
/opencms/opencms/system/modules/uk.co.tableau/templates/docbook-2004-11-
22a.jsp  
User:              (Admin) 
===========================================================

Keeping a shadow VFS in eclipse should minimise the upgrade path and
should minimise the pain in upgrading from OpenCms version X to OpenCms
version X+1.

The issues associated with upgrading from OpenCms 5 to 6 make me nervous
when we go from OpenCms 6 to 7.

Regards
 
Mike



-----Original Message-----
From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Andre Bernardini
Sent: 25 November 2004 09:51
To: opencms-dev at opencms.org
Subject: [opencms-dev] JSP Development with IDEs like Netbeans

Hi,

I'm developing a site which uses jsp's quite extensively. The opencms
editor may
be a good choice for end-users, while it is imho nearly unusable for
developers
(e.g. it misses syntax-highlighting).

Is there a (reasonable) way to develop my jsp's in an IDE like Netbeans
without
having to copy-and-paste it into opencms?

Thanks in advance

so long...
Andre Bernardini

PS: I'm using opencms 5



_______________________________________________
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