Book Image

OpenCms 7 Development

By : Dan Liliedahl
Book Image

OpenCms 7 Development

By: Dan Liliedahl

Overview of this book

<p>OpenCms is a professional-level open-source Website Content Management System, based on Java and XML. Many companies or organizations have requirements that go beyond what is available in the standard OpenCms application. Thankfully, OpenCms can be used by Java developers to create sophisticated add-ons and customizations that extend the power of OpenCms in virtually unlimited directions.<br /><br />Targeting version 7 of OpenCms, this book is for Java developers interested in extending and further customizing OpenCms through its Java API.<br /><br />Starting by showing how to set up a development environment for OpenCms work, the book moves you through various tasks of increasing complexity. Some of the common tasks covered are building OpenCms, XML asset type development, templating, module development, user and role setup, and search integration. In addition to these common tasks some more advanced topics are covered such as self-registering users, RSS support, developing custom widgets and extending the administrative interface. All the topics include examples and are presented while building a sample blog site. <br /><br />The skills you develop will make you an OpenCms developer to be reckoned with!</p>
Table of Contents (16 chapters)
OpenCms 7 Development
Credits
About the Author
About the Reviewer
Preface
Index

Preface

OpenCms can be used by Java developers to create sophisticated add-ons and customizations that extend the power of OpenCms in virtually unlimited directions. Starting by showing how to set up a development environment for OpenCms work, this book moves you through various tasks of increasing complexity. Some of the common tasks covered are building OpenCms, XML asset type development, templating, module development, user and role setup, and search integration. In addition to these common tasks some more advanced topics are covered such as self-registering users, RSS support, developing custom widgets, and extending the administrative interface. All the topics include examples and are presented while building a sample blog site.

This book is a clear, practical tutorial to OpenCms development. It will take you through the development of an example site, illustrating the key concepts of OpenCms development with examples at every stage.

What This Book Covers

Chapter 1 starts out by describing a sample site that will be created to demonstrate OpenCms development concepts. It also provides a description of the developer skills required for OpenCms development, followed by a basic overview of OpenCms architecture. We also provide a basic description of OpenCms configuration files and their file locations.

Chapter 2 sets the stage for coding by providing details on how to set up various OpenCms development environments. The chapter includes a step-by-step procedure for using Eclipse to check out and build OpenCms from the CVS repository. The chapter describes how to build OpenCms using Ant and also how to debug OpenCms itself.

Chapter 3 begins with an explanation of OpenCms modules, including a guide for creating a new module. The module is used to define a new content type, which is another concept covered in the chapter. Included in the content type discussion is a complete, step-by-step guide for designing and creating a new content type used to contain blog entries. All aspects of content type schema files are covered, including schema design, widget usage, field selectors, field validations, nested definitions, and registration. At the end of the chapter, the content type may be used to create new blog entries.

Chapter 4 continues developing the sample site by covering JSP template coding. A set of templates is created to display the blog content, including a complete run through of how they are put together. The example illustrates the use of custom template coding beyond the standard OpenCms tag library by sub-classing Java template classes. Included in the chapter is an overview of the resource and template loading mechanism. Also relating to templates is a description of using expressions and JSTL within template code. Lastly in the chapter is a guide to using WebDAV for template editing in Eclipse.

Chapter 5 covers the usage of Lucene within OpenCms, beginning with an overview of basic Lucene concepts. This is followed by an in-depth guide to creating a search index in OpenCms. The guide provides an example of building a new search index for the blog site example and describes a developer tool, which may be used to perform test queries against the index. The chapter includes a walkthrough of implementing a search form in OpenCms for simple cases and for more advanced situations.

Chapter 6 continues the build out of the sample site by adding support for users and commenting. It starts with an explanation of OpenCms security, including a discussion on Roles, Groups, Users, and Organizational Units. It then proceeds with the set up of the group and role structure for the sample, and shows how they are used within the code.

Chapter 7 shows how easy it is to support user customizations of site pages. It then show an example of this by adding RSS feed support to the sample site, allowing users to specify a custom feed. Included in the chapter is a discussion of integrating third-party libraries into OpenCms.

Chapter 8 describes the custom widget interface, and then shows how to design and create a widget. The widget provides a pluggable data interface that is used to obtain a list of selection values for a select list. The chapter then illustrates how to read XML content fields by creating a list source that gets its values from any content field. Finally, the chapter shows how to localize message strings and how to register and use the custom widget.

Chapter 9 shows how RSS feeds can be generated from OpenCms content. It also shows how wrapper classes can be used around structured content items to make them easier to work with, and then walks through creation of an RSS feed generation module using these concepts.

Chapter 10 discusses how administration points are created in OpenCms, and also how to use OpenCms dialog classes. The chapter also discusses how widgets can be used programmatically. An example administration point is created that ties together topics from previous chapters, showing how to use widgets, dialogs, and multiple screens.

What You Need for This Book

Tools needed and used for this book:

  • MySQL database server

  • Apache Tomcat web server

  • OpenCms 7.0.2 version (New files might have been added in newer version of OpenCms and some files, like jar files, might not be in the book-specified location).

  • Sun Java JDK 1.5

  • Eclipse WTP 1.5.4

  • Apache Ant 1.70

  • Sysdeo Eclipse Tomcat Launcher plug-in

  • Oracle JDBC Driver

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

There are three styles for code. Code words in text are shown as follows: "We can include other contexts through the use of the include directive."

A block of code will be set as follows:

<jsp:useBean id="search" scope="request" class="org.opencms.search.CmsSearch">
    <jsp:setProperty name="search" property="*"/>
    <% search.init(cms.getCmsObject()); %>
       </jsp:useBean>

When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be made bold:

<mappings>
           <mapping suffix=".jsp" />
           <mapping suffix=".html" /> (add this line)
           <mapping suffix=".htm" /> (add this line)
</mappings>

Any command-line input and output is written as follows:

>ant –propertyfile opencms.properties [target]

New terms and important words are introduced in a bold-type font. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: "clicking the Next button moves you to the next screen".

Note

Important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader Feedback

Feedback from our readers is always welcome. Let us know what you think about this book, what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an email to , making sure to mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer Support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the Example Code for the Book

Visit http://www.packtpub.com/files/code/1052_Code.zip to directly download the example code.

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the Submit Errata link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata are added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Questions

You can contact us at if you are having a problem with some aspect of the book, and we will do our best to address it.