Dojo Made Easy
- What Is Dojo?
- Default Dojo Libraries Using Dojo Modules in XPages
- Dojo Modules and Dojo in the Extension Library
- Dojo Extensions to the Edit Box Control
- Dojo Extensions to the Multiline Edit Box Control
- Dojo Extensions to the Select Control
- Dojo Extensions to Buttons
- Composite Dojo Extensions
- Dojo Effects Simple Actions
- Conclusion
- Ever since IBM Lotus Domino Release 8.5.0, the Dojo toolkit has been IBM’s JavaScript framework of choice. It comes preinstalled with the Domino server and is intrinsically linked with the XPages runtime. Much of the standard XPages functionality extends the standard Dojo toolkit. Developers have been integrating Dojo with XPages since its introduction into Domino, taking advantage of the prebuilt code libraries to enhance their XPages applications. Subsequent releases have specifically targeted making it easier to combine XPages and Dojo. To this end, the Extension Library Dojo controls are designed to make it easier still to implement some of the more frequently used modules, whether for novice developers or seasoned developers making extensive use of the Dojo modules and attributes available.
- Developers already familiar with Dojo might want to jump to the section “Dojo Modules and Dojo in the Extension Library.” For those who have never or rarely used Dojo, the following sections will give some background and walk through a couple of examples of Dojo modules in XPages.
What Is Dojo?
Dojo is an open source JavaScript framework, a free collection of cross-browser-compatible functions and widgets, first released in 2006. Each JavaScript file is an object with various attributes and functions, referred to as a Dojo module. For example, dijit.form.TextBox is a Dojo module that converts an HTML input tag to a Dojo-styled text box. Modules can also extend other Dojo modules, so dijit.form.ValidationTextBox and dijit.form.NumberTextBox both extend dijit.form.TextBox. This allows developers to add functionality by creating their own extensions without needing to modify the preinstalled files. One of the strengths of these Dojo modules is that they are specifically designed to support developers in addressing accessibility requirements.
All the XPages Client-Side JavaScript functionality can be found in script libraries in the Dojo root folders; most either extend or mimic standard Dojo modules. For example, any partial refresh calls dojo.xhrGet() or dojo.xhrPost(), the standard Dojo AJAX requests to the server. The XPages DateTimeHelper extends a number of Dojo modules, including dijit.form.Button, dojo.date, and dijit._widget. Client-Side validation also mimics the format of Dojo functions. Consequently, the core Dojo libraries are loaded in an XPage by default, so even a blank XPage in which you are not explicitly including Client-Side JavaScript libraries will include the following Dojo JavaScript libraries, as shown in Figure 5.1:
/xsp/.ibmxspres/dojoroot-1.6.1/dojo/dojo.js
/xsp/.ibmxspres/.mini/dojo/.en-gb/@Iq.js (for English)
Figure 5.1. Dojo libraries loaded.