Publishers of technology books, eBooks, and videos for creative people

Home > Articles

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Presentation

Most applications have some form of presentation. Because presentation in Cocoon is done using XSL stylesheets, you need a working knowledge of this technology to be able to author your presentation. You will also want to look at tools that help you author stylesheets.

One of the major steps is deciding what presentation format you need. Of course, the advantage of Cocoon is that you can add further types of presentations by adding stylesheets as you need them. However, this should not keep you from planning your presentation carefully.

Decide whether you want to support each client application (such as the different browsers) individually or whether you want to go for a format that suits both. Be aware that by the time you have finished your application, a yet-unknown browser might be the market leader.

Design your presentation for speed. This point is not necessarily limited to Cocoon applications, but it is worth stressing. If you plan on presenting your data in HTML, make sure you follow the guidelines as to how you should construct HTML pages for maximum speed when you author your stylesheets. This can depend on the browser type, so refer to available information on this subject.

Make sure you follow the Cocoon paradigm of separating concerns. Even though Cocoon offers you ways of splitting layout and content, it does not force you to. We have seen Cocoon applications built where XHTML was used as the format for the data. Although this might seem like a good idea to start with, after all, XHTML is an XML format. Imagine trying to then provide a presentation layer in WML. As mentioned in Chapter 2, "Building the Machine Web with XML," extracting the actual data from a format like XHTML is quite difficult.

Decide whether your presentation is static or whether it offers personalization of some sort. Check out the later section "Portals" for more information on using personalization to influence the output of your application.

Think about seasonal changes to your presentation. Make your application interesting by making small changes to the web site's appearance, depending on the current season. For example, you could give your site a Christmas feeling during November and December. Write a component such as a selector that provides you with this information.

If you already have HTML pages that you want to reuse in your Cocoon application, this is also possible. You would use the HTML generator to read the HTML and then have a stylesheet format the XHTML into the format you require. This is a way of easing the migration path to a complete XML/XSL-based solution. Another way of migrating is to have the Cocoon solution run in parallel to the application you already have. Cocoon can then generate parts of your site for you. Any new HTML pages can be authored using stylesheets, and the existing site can be served as before.

Even though you might have authored your HTML documents using stylesheets, there will be times when you need to include technologies such as JavaScript in your pages. Another technology that is often used with HTML is Cascading Style Sheets (CSS). CSS is often used to achieve dynamic look-and-feel changes on HTML pages. All of this can be used (or reused) in a Cocoon environment. The site map must be configured to allow the JavaScript (.js) files and the CSS (.css) files to be served through Cocoon. Look into using a reader to do this. Alternatively, these files can be served directly from the web server.

It's possible to use other technologies inside your web pages in the same way. You can use Java applets inside web pages by using the appropriate tags to include them inside the generated HTML pages. Just make sure your .jar file can be served either through Cocoon or directly.

While someone is working on the presentation side of the application, someone else can be defining the content.

  • + Share This
  • 🔖 Save To Your Account