Dynamic Web Development with Seaside

20.1.2Adding the Library

The principle behind using JavaScript is that your application (and the XHTML served by the server) will contain some JavaScript invocations to JavaScript libraries. Therefore you have to mention to your application that it has to include the associate JavaScript libraries.

Seaside 3.0 has reorganised and modularised the Javascript packages, making it easier to load only those parts you need. Furthermore Seaside 3.0 gives you the possibility to chose between a full version for development, a minimized and compressed version for deployment, and a minimized and compressed version served through the Google AJAX Libraries API high-performance servers. In any case the end result should be the same.

Before being able to use any of the functionality provided by the Scriptaculous package, you need add the classes PTDeploymentLibrary and SUDevelopmentLibrary to our application. These are the normal file libraries that automatically includes the necessary JavaScript sources into the XHTML head of our application. There are two alternative ways of adding the Javascript libraries:

  • Add the library using the application configuration interface by selecting PTDeploymentLibrary and SUDevelopmentLibrary from the list and clicking on Add.
  • Add the library with the Seaside API, preferably in the initialize method on the class side of the root component. Don’t forget to evaluate the method after adding or changing it.
ToDoListView class>>initialize
(WAAdmin register: self asApplicationAt: 'todo')
addLibrary: PTDeploymentLibrary;
addLibrary: SUDeploymentLibrary

If you fail to specify PTDeploymentLibrary and SUDeploymentLibrary in your application, you will not get a Seaside error message, but you will get a Javascript error message that is sometimes hard to diagnose, depending on the web browser you are using.

Copyright © 19 March 2024 Stéphane Ducasse, Lukas Renggli, C. David Shaffer, Rick Zaccone
This book is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 license.

This book is published using Seaside, Magritte and the Pier book publishing engine.