- 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
Dojo Modules and Dojo in the Extension Library
As the examples in the preceding sections demonstrate, some Dojo modules are easy to implement into XPages, but others are more convoluted. Even for a confident developer already accustomed to using dijits in applications, it could get annoying to have to keep adding dojoTypes and dojoAttributes to all core controls, which was one of the driving forces behind implementing the Dojo controls in the Extension Library. Using native controls offered several other benefits:
- Easier to implement drag-and-drop functionality
- Promoting some of the more common Dojo modules available for use within XPages
- Validating and manipulating values
- Limiting the number of controls that need to be dropped onto the XPage or Custom Control
That is not to say that the Extension Library precludes the need to implement Dojo manually within XPages. It does not, nor is it intended to. Some Dojo modules, such as the dojox.image.Lightbox control, are not available in the Extension Library controls. Equally, there might be instances in which developers have created their own Dojo extensions that they still intend to use but do not have the skills or are not ready to componentize.
Benefits and Differences of Dojo Extension Library Components
By componentizing the Dojo modules as extended controls, the Extension Library offers several benefits. Performance is one aspect. Another is that if a Dojo control from the Extension Library is used, dojoParseOnLoad or dojoTheme does not need to be set and the relevant Dojo module(s) does not need to be added to an XPage. Whether accustomed or not to adding the gamut of dojo attributes to Dojo controls, the extended controls also avoid the need to remember (and indeed avoid mistyping!) dojo attributes. This also means that it is quicker to implement the extended controls than just setting a Dojo type and attributes, whether dragging and dropping and using the “pretty panels” or typing directly into the Source pane. And for developers who are integrating with Java beans, controls also allow options for integration with backend Java classes, whether with valueChangeListeners or for controlling return types of, for example, the Dojo Number Text Box or Dojo Number Spinner.
However, for dijits to use a Dojo theme other than tundra, the code outlined in Listing 5.5 for a Theme design element is still required to apply the relevant Dojo theme to the body tag. There is nothing within the Extension Library to short-circuit that requirement.
In the examples that follow, properties of the Extension Library are hard-coded, for ease of explanation. But remember that, as with any other property in XPages, the value of all the properties of the Extension Library controls can be programmatically calculated, either using on page load or dynamically.
Without further ado, let’s start looking at the Dojo form controls from the Extension Library that add to the form controls we covered in the previous chapter. Other Dojo controls are covered in subsequent chapters. For example, the Dojo Data Grid control is covered in Chapter 7, “Views.”