Ajaxdo – Getting started

Ajaxdo 1.1:

Content

Ajaxdo contains 3 folders:
1) ./Ajaxdo/ -Contains the JavaScript implementation (Ajaxdo.js)
2) ./ajaxdo_php/ -Contains the server side implementation of Ajaxdo in PHP
Note: next releases of Ajaxdo will contain ajaxdo_java and ajaxdo_net for other server side language support.
3) ./examples/ – contains simple web applications that use Ajaxdo

The Ajaxdo JavaScript object:

Constructor:

* Ajaxdo(appContext) – the appContext parameter refers to the table name where the JavaScript objects will be stored on the server database.

Methods:

* saveObject(objectName, object) – saves/updates a javascript object on the server side. Parameter objectName refers to the primary key of the object (used in delete/loadObject) and Parameter object is any JavaScript object (data structure like array, hash-maps and custom objects).

* loadObject(objectName) – loads and returns a JavaScript object that was previously saved. Parameter objectName refers to the primary key of the object (set in saveObject).

* deleteObject(objectName)– deletes a JavaScript object that was previously saved. Parameter objectName refers to the primary key of the object (set in saveObject).

* listObjects() – returns an array of object names that are the primary key for objects saved in this application context (this DB table)

Members:

* loadURL – The URL of the server side implementation that is responsible for loading objects (for example http://someDomain/ajaxdo_php/load.php)

* saveURL – The URL of the server side implementation that is responsible for saving objects (for example http://someDomain/ajaxdo_php/save.php)

* deleteURL – The URL of the server side implementation that is responsible for deleting objects (for example http://someDomain/ajaxdo_php/delete.php)

* listURL – The URL of the server side implementation that is responsible for listing objects (for example http://someDomain/ajaxdo_php/list.php)

These URLs can be modified at runtime, see the examples in the release.

Server side implementation

Ajaxdo PHP implementation

The ajaxdo_php folder contains a set of PHP script that implements the Ajaxdo server side API.

config.php holds the database configurations such as schema, user and password. Please configure this file according to your database definitions.

Ajaxdo Java implementation

Since Ajaxdo 1.1
The ajaxdo Java server side implementation is composed of four JSP files (delete.jsp, load.jsp, list.jsp, save.jsp) and one data access object called org.ajaxdo.db.AjaxdoDAO.
AjaxdoDAO implementation relays on JNDI Datasource (review the serverside corrections to this document). The Datasource JNDI-resource name should be “java:comp/env/jdbc/AjaxdoDB1”.

All examples have been modified to work both with PHP and Java and enable runtime switching between them. Please note that the samples load by default with the PHP version. To start the example with a Java server side implementation, see the comments in the example body and uncomment the necessary parts.
This release was tested under tomcat 5 and MySQL 5.

Ajaxdo database configuration

In Ajaxdo javascript objects are stored in a server-side database, the example applications where tested in MySQL 5.0.2.4.

The name of the database table where Ajaxdo saves the javascript objects is called the application context. The application context is passed in the constructor of the Ajaxdo JavaScript object every time it is created (… new Ajaxdo(appContext)).
Each web application can use several database tables (via multiple instances of Ajaxdo and application context). It is recommended that two logically-separate web application use different application context.
For each application context there needs to be a correlating database table with the following columns:

OBJECT_NAME – varchar(45) – primary key
OBJECT_DATA – text
OBJECT_TYPE – int(10)

Here is an example of the SQL statement that creates the table for the excel example application:

CREATE TABLE `ajaxdo`.`ajaxdo_excel` (
`OBJECT_NAME` varchar(45) NOT NULL,
`OBJECT_DATA` text NOT NULL,

`OBJECT_TYPE` int(10) unsigned NOT NULL default '1',
PRIMARY KEY (`OBJECT_NAME`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

An example use of Ajaxdo can be found in the current release under the example folder.

Leave a Reply