Quantcast
Channel: XPages – Xcellerant
Viewing all articles
Browse latest Browse all 216

Dojo in XPages – 1: Overview

$
0
0

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.

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.



Viewing all articles
Browse latest Browse all 216

Trending Articles