Dojo in XPages – 1: Overview
Dojo in XPages Series
The Case for Libraries
Even more importantly, libraries generally provide cross-browser support with the provided features so you don’t have to worry about it. If you’ve ever spent time writing code that has to support several versions of IE along with other browsers, you understand how much time and hassle this will save you.
The Dojo toolkit is comprised of 4 main packages. Here is a list and description, taken directly from the Dojo documentation:
- dojo – Sometimes referred to as the “core”, this is the main part of Dojo and the most generally applicable packages and modules are contained in here. The core covers a wide range of functionality like AJAX, DOM manipulation, class-type programming, events, promises, data stores, drag-and-drop and internationalization libraries.
- dijit – An extensive set of widgets (user interface components) and the underlying system to support them. It is built fully on-top of the Dojo core.
- dojox – A collection of packages and modules that provide a vast array of functionality that are built upon both the Dojo core and Dijit. Packages and modules contained in DojoX will have varying degrees of maturity, denoted within the README files of each package. Some of the modules are extremely mature and some are highly experimental.
- util – Various tools that support the rest of the toolkit, like being able to build, test and document code.
The core functions are automatically available to XPages applications. Many XPages components are built on dijits, but if you want to use dijit or dojox modules, you’ll need to include them on your page. I do not believe that the
util package is included with Domino.
There’s decent help available online, but you need to pay attention to the Dojo version number built into your current version of Domino in order to find the correct reference.
- Domino 8.5.1 – Dojo 1.3.2
- Domino 8.5.2 – Dojo 1.4.1
- Domino 8.5.3 – Dojo 1.6.1
- Domino 9.0 – Dojo 1.8.1
- Domino 9.0.1 – Dojo 1.8.3
You can install a different version of dojo on the server and change it server-wide or on a per-application basis, but I would not recommend it unless you have a very compelling reason. A lot of XPages functionality depends on Dojo, so tread lightly.
Other libraries provide many of the same features. However, another library may provide more code or more plugins for additional features that aren’t available in the base library.
The most popular library is jQuery, and Mark Roden has written extensively on using it with XPages.
The downside is that it’s an additional library to load, so there’s some extra overhead.
If you need features and plugins that Dojo doesn’t provide, by all means, use another library. But if you can accomplish the task with a similar amount of effort, then be in the habit of using the functionality that’s already available.
There’s way more to Dojo than I could possibly cover, but I’ll highlight key features that I hope you’ll find most useful.