Dojo in XPages – 1: Overview

Dojo is a client-side JavaScript library that is included on the Domino server and is automatically available within XPages application. As with any library, it contains many features that save you time by providing many features so that you don’t have to take the time to write them yourself. In this series, I’ll cover basic Dojo functionality and explore how you can use it to increase your productivity and your applications’ functionality.

Dojo in XPages Series

Dojo in XPages — All Blog Posts

The Case for Libraries

Several client-side JavaScript libraries are available. They provide features that you can easily use in order to speed up your development time. For example, you may need some string or array manipulation logic that doesn’t exist in core JavaScript, but a library might provide it so you don’t have to take time writing it. Libraries also make it easy for you to add/remove elements on a page, change styles, move elements, provide animation, draw simple charts, and more. This lets you focus your time on your business logic rather than on the supporting functionality.

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.

Dojo Packages

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.

Dojo Version

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 JavaScript Libraries

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.


6 responses to “Dojo in XPages – 1: Overview”

  1. Richard Moy says :

    Brad, maybe you can help me explain one thing with Dojo on XPages. If I use the default Dojo with XPages, the Dojo library does not remain cached in the browser when I switch to different page. However, if I call my own Dojo library it is cached on the browser and new requests is not made again.

  2. devin says :

    How to redirect to an url in Xpages in client side ?

  3. James says :

    Hi Brad, I’ve just started dabbling with XPages. It seems no matter what I do, I haven’t been able to get any Dojo/Dojox results. I’ve found many snippets that I’ve tried to implement, and it normally only results in the raw data being portrayed, with no interaction capabilities or movement effects as expected (Drag and Drop and the Rotator specifically). Without getting too detailed on my attempts, is it possible that the Notes Administrators have either removed the Dojo modules from our Notes servers, or is it most likely my own implementation errors?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: