Sunday, July 16, 2006

Imp links

Fifty essential topics on Economics :


Presentation Tips:

Tips for bloggers:

Notes Tips:!OpenNavigator&87256B280015193F8725708C006887EE

Lotus Geek:

Multilingual Applications in Domino:

Project Management References:


Tuesday, July 11, 2006

Domino and Ajax

What is it?
Ajax is only a name given to a set of tools that were previously existing. The main part is XMLHttpRequest, a class usable in JavaScript , that was implemented into Internet Explorer since the 4.0 version. The use of XMLHttpRequest by Google (Gmail and GoogleMaps) brought this format to limelight.

Ajax is shorthand for Asynchronous JavaScript and XML (and DHTML, and so on). The phrase was coined by Jesse James Garrett of Adaptive Path and is, according to Jesse, not meant to be an acronym.

The building blocks for Ajax applications are:
HTML/ DHTML - Web forms
JavaScript – communicates with server applications.
Document Object Model (DOM) - to access data inside the page or to access elements of Xml file read on the server
The XMLHttpRequest class read or send data on the server asynchronously.

Why to use Ajax?
Mainly to build a fast, dynamic website, but also to save resources. For improving sharing of resources, it is better to use the power of all the client computers rather than just an unique server and network. Ajax allows to perform processing on client computer (in JavaScript) with data taken from the server. The processing of web page formerly was only server-side, using web services or Php scripts, before the whole page was sent within the network. But Ajax can selectively modify a part of a page displayed by the browser, and update it without the need to reload the whole document with all images, menus, etc... For example, fields of forms, choices of user, may be processed and the result displayed immediately into the same page.

How does it works?
Ajax uses a programming model with display and events. These events are user actions, they call functions associated to elements of the web page. Interactivity is achieved with forms and buttons. DOM allows to link elements of the page with actions and also to extract data from Xml files provided by the server.
To get data on the server, XMLHttpRequest provides two methods:
- open: create a connection.
- send: send a request to the server.

Data furnished by the server will be found in the attributs of the XMLHttpRequest object:
- responseXml for a Xml file or
- responseText for a simple text.

Take note that a new XMLHttpRequest object has to be created for each new file to load.

We have to wait for the data to be available to process it, and in this purpose, the state of availability of data is given by the readyState attribute of XMLHttpRequest.

States of readyState follow (only the last one is really useful):
0: not initialized.
1: connection etablished.
2: request received.
3: answer in process.
4: finished.


Create two text fields:

Write the javascript code on the button:

Create a Lotus Script agent '(GetData)', with the following code:

Sub Initialize
Dim loSession As New NotesSession
Dim loDb As NotesDatabase
Dim loVw As NotesView
Dim loDoc As Notesdocument
Dim loCurrDoc As NotesDocument

Set loDb = loSession.CurrentDatabase
Set loVw = loDb.getView("area")
Set loCurrDoc = loSession.DocumentContext

Dim lsQS As String
Dim lsArea As String
Dim liCount As Integer
lsQS = loCurrDoc.Query_String(0)
lsArea = Strright(lsQS, "=")
Set loDoc = loVw.GetDocumentByKey(lsArea, True)

If Not loDoc Is Nothing Then
liCount = loDoc.Count(0)
End If
Print liCount

End Sub

That's it! Open your form and play with it!

Server load for all the user requests. For example, a type-ahead script that posts back to get the newest results can have multiple requests. Imagine 1000 people using it with large words. How many requests is that?

Cross-browser compliance of Javascript can be a hindrance.