Ajax Domino Controller

Ajax Domino Controller is a Domino web development framework by using AJAX javascript and Domino Agent.

It provides web developers to retirve Domino data with no COM object nor CORBA framework, just javascript function call and XML for communication.

 

Now, the released version is 0.1.0 and also many functions need to be developed and tested. You can download the Ajax Domino Controller template and ajaxdomino.js for using on your web page with Domino environment.

 

Also, you need to download the prototype.js on http://prototypejs.org/download, and used on your web pages by adding the following scripts.

 

  <script src="path/to/prototype.js" type="text/javascript"></script>
  <script src="path/to/ajaxdomino.js" type="text/javascript"></script>

In ajaxdomino.js, you can use dblookup to retrive XML data like Formula @DBLookup does.

You provide server,database,view,key,field and onComplete function to handle the XML data with your page.

In the parameter field, you can provide ColumnNumer or fieldName to do with, and not only one column or one field can do,

you can retrive two or more field value by useing comma with it.

 

e.g. dblookup('myserver','mydb','myview','mykey','field1,field2,field3','myCompletefunction');

 

// Change the bold block to your Domino IP/domain name


function dblookup(server,database,view,key,field,onComplete){
  var pars='action=dblookup'+
           '&server='+escape(server)+
           '&database='+escape(database)+
           '&view='+escape(view)+
           '&key='+escape(key)+
           '&field='+escape(field);
  //alert(pars);
  var myAjax=new Ajax.Request(ajaxdominocontrollerurl, {
    method: 'get',
    parameters: pars,
    asynchronous: true,          
    onComplete: eval(onComplete),
    onSuccess: function(resp) {
      //alert("The response from the server is: " + resp.responseText);
    },
    onFailure: function(resp) {
      alert('Sorry. There was an error.');
    },
    onException: function(resp, exception) {
      var description = '';
      for (var property in exception) {
        description += property + '=' + exception[property] + '\n';
      }
      alert('Exception: ' + exception + '\n' + description);
    }
  });        
}

 

The prototype AJAX object will take handle with the Ajax Domino Controller agent "ActionListener" and pass the parameters through Domino web container.

As the ActionListener agent received the request, it will parse the action field and switch to the properly function to do with.

 

The Ajax Domino Controller also provide an error handling function call to send email on the error raised event.

You should also change the constant variable "Administrator" in the ErrorHandling script library to your desired email,

and testing the agent on your Domino server.

 

Be remided, you should create a new Database with the template "AjaxDominoController.ntf" on your Domino server,

sign the database you created with your Adminstration account and change the ACL of "default" from Administrator to Reader.

 

After the responsed XML returned, it will call the onComplete function you provided with dblookup function call, it will look like this

 

    function showResponse(resp) {
      //alert(resp.responseText);
      var xmlDoc=resp.responseXML;
      var x
      
      x=xmlDoc.getElementsByTagName(Field);
      $('Result').innerHTML="<select id='lst'><option></option></select>";
      for (var i=0;i<x.length;i++)
      {       
        var value = x[i].childNodes[0].text;
        $('lst').options[i]=new Option(value,value);
      }
    }

    .....

 

    <div id="Result"></id>

 

Very straight forward, enjoy it.

 

 

 

張貼留言