Dojo 1.4 sports a fantastic tree widget, complete with ARIA compliance, keyboard accessibility, and internationalization (including right-to-left layout for appropriate countries and languages). For large tree data sets, we want to be able to only load the necessary data for the visible nodes of the tree. As a user expands a node, we then want to load the children of that node. Ideally, we only want to make one HTTP request per expansion for optimal performance. Historically, effective lazy loading has been a challenge, but some recent additions will make it much easier to utilize efficient lazy loading mechanisms in the tree.
Author Archive
Efficient Lazy Loading of a Tree
Wednesday, January 27th, 2010Getting Started With Pintura
Monday, January 25th, 2010Pintura is a REST-style web framework that utilizes a layered approach to application development that facilitates straightforward, well-designed rich internet applications. Pintura forms the core web framework for Persevere 2.0, and consists of a powerful data modeling and persistence framework called Perstore, in combination with a REST-style web framework. You can read more about the goals and principles behind Pintura, but here we will look at how to get started writing applications.
Pintura-based applications normally consist of server-side data models with three layers: data stores, store models, and model facets. On top of this, different representation handlers (for serializing data to different formats) can be defined, but Pintura comes with a good set of these ( including JSON, JavaScript, multipart, and Atom), so usually that is not necessary. This provides a well-structured separation of concerns, distinguishing storage configuration (data stores), core data logic (models), varying capabilities of access to the data (facets), and data serialization (representations). Perhaps the easiest way to understand this approach to take a look at an example application.
Introducing Pintura
Friday, January 22nd, 2010Pintura is a CommonJS/JSGI-compliant, server-side JavaScript-based framework for building rich Internet application with the REST architectural style, thin storage-oriented server design, and the consistency of end-to-end JavaScript. The Pintura framework forms the core of Persevere 2.0, and is the first framework built to run on multiple CommonJS platforms like node.js, Narwhal/Jack, and Flusspferd/Zest. It utilizes a layered approach to application development that facilitates straightforward, modular web applications.
Pintura is not a traditional MVC web server framework, which often conflate presentation and interaction concerns across the client and server, but rather follows the REST prescription of maintaining simple storage and serialization oriented server also known as thin server architecture or SOFEA. Pintura is designed to cleanly separate the concerns of presentation and interaction on the client, and storage and model logic concerns on the server. This design fits perfectly with comprehensive JavaScript frameworks like Dojo, General Interface, Cappuccino, YUI, and ExtJS that provide client-side MVC. In particular, Dojo has excellent support for standards-based JSON REST interaction that matches perfectly with this server-side framework.
CommonJS/JSGI: The Emerging JavaScript Application Server Platform
Tuesday, January 19th, 2010CommonJS (formerly known as ServerJS) has become the essential hub around the development of server side JavaScript (SSJS). SSJS for years has suffered from fragmentation, but the CommonJS project has provided the momentum to bring different frameworks together and start building interoperable modules. SSJS is ripe with potential; JavaScript has been soaring in popularity and the ECMAScript 5 specification was recently accepted. JavaScript has proven itself as the language of the web’s client-side (even ActionScript is a derivative of JavaScript). The opportunity to use the same language on both client and server is certainly most realistic and viable with JavaScript as it avoids the need for translation.
CommonJS
CommonJS has focused on developing critical APIs for building reusable modules, particularly for server-side JavaScript environment. The server-side is generally based around database interaction, file I/O, HTTP serving, and the generation of data formats and HTML, whereas the client-side is based around DOM manipulation and the browser object model. There are certainly APIs that can be used on both sides, and JavaScript on the client and server invites the reuse of APIs where possible. The WebWorker, Indexed Database, and XHR APIs are promising to be enormously beneficial on the server side, and with excellent client server consistency. But still the server side requires special attention, and CommonJS is bringing the needed standards and conventions.
Persevere 1.0
Friday, November 13th, 2009Persevere 1.0 is now available for download. Persevere is a JavaScript storage and application server that uses a standards-based interface of HTTP/REST, JSON-RPC, JSONPath, and REST Channels. Persevere is designed for rich client applications and can be used with any framework or client. The Persevere Server runs on Rhino and provides persistent data storage of dynamic JSON data in an interactive server side JavaScript environment with the following key features:
- Create, read, update, and delete access to persistent data through a standard JSON HTTP/REST web interface
- Dynamic object persistence – expando objects, arrays, and JavaScript functions can be stored, for extensive JavaScript persistence support
- Remote execution of JavaScript methods on the server through JSON-RPC for a consistent client/server language platform
- Flexible and fast indexed query capability through JSONQuery/JSONPath
- Comet-based data monitoring capabilities through HTTP Channels with Bayeux transport plugin/negotiation support
- Data-centric role-based object level security with user management, Persevere is designed to be accessed securely through Ajax with public-facing sites
- Comprehensive referencing capabilities using JSON referencing, including circular, multiple, lazy, non-lazy, cross-data source, and cross-site referencing for a wide variety of object structures
- Data integrity and validation through JSON Schema based definitions
- Class-based data hierarchy – typed objects can have methods, inheritance, class-based querying
- Pluggable data source architectures – SQL tables, XML files, remote web services can be used as data stores
- Object versioning with transactional history of record states
Persevere in use
Recently, Cramer Development put together a slick little application for making sticky notes. They discuss how quickly the application came together, as Persevere allowed them to quickly establish a data API, and then focus on the client side interface.
Other users include:
- DataStream Content Solutions is using Persevere to build an XML repository for legal data in combination with MarkLogic.
- Montana State University is using Persevere for their Yogo Data Management Project.
- Another multi-national company is using Persevere in production for Intranet applications, with consistent usage from a number of users.
- And, of course, we at SitePen are using Persevere for a number of the applications we are developing.
Numerous others are using Persevere in a variety of ways.
Learning more
There are a number of resources for learning more about Persevere and getting started with it.
- Persevere Documentation
- Download Persevere
- SitePen Persevere Support
- SitePen Persevere Blog
- Getting Started with Persevere Using Dojo
- Persevere Mailing List
- Persevere + Dojo (using Comet) demonstration
What’s Next
With Persevere 1.0 finished, we are already working on the next version which will be based on the new Pintura architecture. Pintura is the new JavaScript core for the Persevere HTTP interface that is based on the CommonJS and JSGI API. Pintura will run on any CommonJS/JSGI capable JavaScript engine (support for V8, JSCore, and Spidermonkey coming).
JSON Namespacing
Wednesday, September 2nd, 2009(or “Why JSON Hyper Schema means JSON doesn’t need XML’s namespacing colon cancer”)
I recently posted a proposal for an addition to JSON Schema, called JSON Hyper Schema, for defining the properties of a JSON structure that represent links or references within data structures. This is intended to provide the same linking capabilities of JSON Referencing, but in a much more flexible manner such that schemas can be used to describe link information in existing data structures without requiring a fixed convention. I wanted to exposit one of the further benefits of using this type of schema: satisfying the goals of namespacing in JSON.
Narwhal on Persevere
Tuesday, September 1st, 2009Narwhal is an open source toolkit for server-side JavaScript that delivers a growing library of useful modules implementing the CommonJS standard library API. CommonJS is an effort to provide a standard library for server side JavaScript (or JavaScript in any privileged environment) and Narwhal is the most extensive implementation of the library API. Narwhal provides numerous system level functions and IO capabilities with streaming and File interaction.
Persevere is a framework for server-side JavaScript with object persistence and direct mapping to RESTful HTTP interaction. These two projects can complement each other very nicely and since Persevere implements the CommonJS API for module loading, Narwhal’s standard library of modules can now easily be utilized within Persevere.
MVC in the Browser
Friday, August 28th, 2009The Model-View-Controller (MVC) is one of the most pervasive patterns in software engineering, and is widely accepted as an important paradigm for separation of business logic from presentation logic. Recently there have been some discussions around the use of the MVC pattern within the browser/JavaScript environment. It is easy to look for duplication of the web-framework-specific MVC patterns and miss the significant true (truer in some senses) MVC patterns that already exist in the browser and are augmented by the modern JavaScript toolkit.
The MVC pattern describes the conceptual organization of logic and flow in an application. It would be naive to assume that one needs a module, package, or a class called a “Model”, “View”, or “Controller” in order to implement MVC. There are some great JavaScript libraries that explicitly call out these terms, but the foundation for the view and controller are well established in the browser environment. One can properly leverage and build upon these concepts in the browser to have a well designed MVC structure without necessarily using such terms in your code. MVC can guide design while letting the application’s conceptual function and purpose dictate organization.
Unobtrusive JavaScript Typing via JSON Schema Interfaces
Tuesday, June 23rd, 2009One of the frequently expressed frustrations with JavaScript, especially from users coming from more static languages, is the lack of typing capabilities in JavaScript. Typing provides the ability to define and enforce contracts between interfaces such that interactions can be validated before violated assumptions result in later difficult-to-find bugs. On the other hand, many users that have grown fond of JavaScript have come to enjoy the fast and free style, and the minimalism of simply defining behavior without needing to make extra type definitions. However, these two coding preferences do not need to be mutually exclusive.
The abandoned ES4 effort made a valiant attempt to add typing (without losing dynamism) via gradual typing; however this still demanded the inclusion of intrusive typing annotations—thus adding type constraints to code polluted the otherwise simple direct JavaScript programming style necessitating more complex, difficult-to-follow code. Other efforts include libraries to define types on functions without extending syntax.
It is now possible to unobtrusively define type constraints on properties and methods in JavaScript with portable JSON schema based definitions called JSON schema interfaces (JSI). JSI is a typing system for JavaScript that does not force any new syntax on JavaScript. Schema structures can be used to define the type constraints in a way that works with existing JavaScript classes and objects.
Using REST Channels with cometD
Monday, June 15th, 2009REST Channels provides a mechanism for receiving notifications of data changes and integrates Comet-style asynchronous server sent messages with a RESTful data-oriented architecture. Dojo includes a REST Channels client module which integrates completely with Dojo’s JsonRestStore, allowing messages to be delivered through the Dojo Data API seamlessly to consuming widgets, with minimal effort. The REST Channels module will automatically connect to a REST Channels server, like Persevere (which offers REST Channels out of the box). However, existing infrastructure may necessitate the use of an alternate Comet server like Jetty’s cometD server. REST Channels can be used on top of another Comet protocol like Bayeux’s long-polling protocol and with a little bit of reconfiguration, you can use Dojo’s REST Channels with a cometD server to achieve Comet-REST integration.
